libs/std.@
Table of Contents
Function count: 46
Click on genres to show all functions in that genre.
| (functional) | Do, DoHelper, Generate, Left, MakeFunction, MapLeft, MapRight, Nilad, Once, Right, Thrice, Twice |
| (functional/string) | OverChars, OverGrid |
| (IO) | Echo, Output, Printf, ReadNumbers |
| (list) | Behead, Betail, CellReplace, ChopInto, Mean, MinMax, Norm, Order, Pairs, Triples |
| (list/matrix) | PadMatrix |
| (number) | Distance |
| (numeric) | Divisors, Point, ProperDivisors, RawDivisors, ReIm |
| (numeric/bases) | BaseBelow, BaseRange, BinBelow, BinRange, HexBelow, HexRange, OctBelow, OctRange |
| (numeric/prime) | PrimePi |
| (string) | HeatMap, S |
BaseBelow[number base, number n] → [[number]] (numeric/bases)
Returns an array of base base digits less than base ^ n. BaseRange[number base, number ...args] → [[number]] (numeric/bases)
Returns an array of base base digits of the numbers found in Range[...args] Example
Print => BaseRange[2, 0, 10]
?? [0, 0, 0, 1]
?? [0, 0, 1, 0]
?? [0, 0, 1, 1]
?? [0, 1, 0, 0]
?? [0, 1, 0, 1]
?? [0, 1, 1, 0]
?? [0, 1, 1, 1]
?? [1, 0, 0, 0]
?? [1, 0, 0, 1]
?? [1, 0, 1, 0]Behead[[(*)] list] → [(*)] (list)
Returns all but the first element of list. Betail[[(*)] list] → [(*)] (list)
Returns all but the last element of list. BinBelow[number n] → [[number]] (numeric/bases)
Returns an array of base 2 digits less than 2 ^ n. BinRange[number ...args] → [[number]] (numeric/bases)
Returns an array of base 2 digits of the numbers found in Range[...args] CellReplace[(*) cond, (*) with, [(*)] list] → [(*)] (list)
Curries.
Replaces all cells inlist matching cond with with. Example
mat1 := Identity[4]
Display[CellReplace[0, 9, mat1]]
?? 1 9 9 9
?? 9 1 9 9
?? 9 9 1 9
?? 9 9 9 1
mat2 := Integers[3, 3]
Display[CellReplace[Odd, Square, mat2]]
?? 0 1 2
?? 9 4 25
?? 6 49 8
Print[CellReplace[Positive, `-, -4:4]]
?? [-4, -3, -2, -1, 0, -1, -2, -3, -4]ChopInto[[(*)] x, number n] → [[(*)]] (list)
Splits x into n groups. Example
Print[ChopInto[1:6, 3]]
?? [[1, 2], [3, 4], [5, 6]]Distance[[(*)] p1, [(*)] p2] → number (number)
Returns the distance between points p1 and p2 on the Euclidean plane. Example
Print[Distance[ [1, 2], [1, 4] ]]
?? 2.0
Print[Distance[ Point[0, 0], Point[5, 12] ]]
?? 13.0
Print[Distance[ -3-4i, 3+4i ]]
?? 10.0
Print[Distance[ [0, 0], [1, 1] ]]
?? 1.4142135623730951Divisors[number n] → [number] (numeric)
Returns all positive integers which divide n. Do[fn f, n= nil] → [(*)] (functional)
Calls f n times with no arguments, collecting the results into an array. Echo[(*) ...args] → [(*)] (IO)
Print, but without a trailing newline. Generate[(*) ...args, cond fn] → (*) (functional)
Synonym for GenerateFirst[N, ...args]. HeatMap[[[number]] mat, [(*)] legend?, number min?, number max?] → string (string)
Returns a string of characters which represent the "weight" of certain elements. Example
Print[HeatMap[1:5]]
?? -\[G@
Print[HeatMap[1:5:5]]
?? -\[G@
?? \[G@
?? [G@
?? G@
?? @
Print[HeatMap[1:5:5, UTF8_LEGEND]]
?? ░░▒▒▓
?? ░▒▒▓
?? ▒▒▓
?? ▒▓
?? ▓
Print[HeatMap[1:5:5, "01"]]
?? 00001
?? 0001
?? 001
?? 01
?? 1
Print[HeatMap[PascalTriangle[10]]]
?? -
?? --
?? ---
?? ----
?? -...-
?? -.__.-
?? -.:,:.-
?? -`,cc,`-
?? -`;T*T;`-
?? -`cl[[lc`-
?? -_r)U@U)r_-
Print[HeatMap[PascalTriangle[7] % 2, " ."]]
?? .
?? ..
?? . .
?? ....
?? . .
?? .. ..
?? . . . .
?? ........HexBelow[number n] → [[number]] (numeric/bases)
Returns an array of base 16 digits less than 16 ^ n. HexRange[number ...args] → [[number]] (numeric/bases)
Returns an array of base 16 digits of the numbers found in Range[...args] Left[(*) ...args] → (*) (functional)
Returns the leftmost argument given. Example
Print[Left[1, 2, 3, 4]]
?? 1MakeFunction[(*) x, fn bonder?] → fn (functional)
Returns x if it is a function, otherwise returns a constant function returning x. Arguments
fn bonder? - If specified, returns a function with x as its left argument instead of a constant function.
MapLeft[fn f] → fn (functional)
Returns a function with arguments l and r which calls f[e, r] for each element e in l. MapRight[fn f] → fn (functional)
Returns a function with arguments l and r which calls f[l, e] for each element e in r. MinMax[[(*)] list] → [(*), (*)] (list)
Returns the minimum and the maximum of list in a 2-element array. Example
list := [1, 9, 3, -5, 0, 0, 12]
Print[MinMax[list]]
?? [-5, 12]Nilad[fn f] → fn (functional)
Returns a function which calls f with no arguments. Example
print3 := Nilad[Print&3]
print3[]
?? 3
print3["Hello!"]
?? 3Norm[[(*)] x] → number (list)
Returns the norm of x. Example
Print[Norm[3'4]]
?? 5.0
Print[Norm[-2+1i]]
?? 2.23606797749979OctBelow[number n] → [[number]] (numeric/bases)
Returns an array of base 8 digits less than 8 ^ n. OctRange[number ...args] → [[number]] (numeric/bases)
Returns an array of base 8 digits of the numbers found in Range[...args] Once[fn f] → (*) (functional)
Calls f once with no arguments. Example
Once[Print<~3, 4~>]
?? 3 4
Print[Once[V]]
?? []Order[[(*)] x] → number (list)
Returns the dimensionality of x. Example
Print[Order[10]]
?? 0
Print[Order["Hello! :D"]]
?? 0
Print[Order[1:5]]
?? 1
Print[Order[Identity[3]]]
?? 2
Print[Order[ [[[[[9]]]]] ]]
?? 2 (broken, since Dim is currently broken)Output[(*) ...args] → [(*)] (IO)
Prints each element in args, separated by newlines, with no trailing newline. Returns args. OverChars[fn f] → fn (functional/string)
Returns a function which applies f to the charcters in a string. This returns a string. OverGrid[fn f] → fn (functional/string)
Returns a function which applies f to the grid of charcters in a string. This returns a string. PadMatrix[[[(*)]] ragged, (*) padwith?, fn padf?] → [[(*)]] (list/matrix)
Makes ragged a rectangular matrix, padding to the right with padwith. Example
Display[PadMatrix[1:5:5]]
?? 1 2 3 4 5
?? 2 3 4 5 0
?? 3 4 5 0 0
?? 4 5 0 0 0
?? 5 0 0 0 0
Display[PadMatrix[1:5:5, 9, PadLeft]]
?? 1 2 3 4 5
?? 9 2 3 4 5
?? 9 9 3 4 5
?? 9 9 9 4 5
?? 9 9 9 9 5Pairs[[(*)] list] → [(*)] (list)
Returns all overlapping slices of size 2 in list. Example
Print[Pairs[1:5]]
?? [[1, 2], [2, 3], [3, 4], [4, 5]]Point[number x, number y] → Point (numeric)
Point class. Example
origin := Point[0, 0]
Print[origin]
?? (0, 0)
pythag := Point[3, 4]
Print[pythag]
?? (3, 4)PrimePi[number n] → number (numeric/prime)
Returns the number of prime numbers less than or equal to n. Example
Print[PrimePi[0:10]]
?? [0, 0, 1, 2, 2, 3, 3, 4, 4, 4, 4]Printf[(*) ...args] → [string] (IO)
Calls Format[...args], which is passed then to Print. ProperDivisors[number n] → [number] (numeric)
Returns all divisors of n, except n. RawDivisors[number n] → [number] (numeric)
Returns all positive integers which divide n which are also less than or equal to Sqrt[n]. ReadNumbers[] → [number] (IO)
Reads a line of STDIN and converts each entry to a number, space-separated. ReIm[(*) n] → [number] (numeric)
Returns the real and imaginary portions of n. Right[(*) ...args] → (*) (functional)
Returns the rightmost argument given. Example
Print[Right[1, 2, 3, 4]]
?? 4Thrice[fn f] → [(*)] (functional)
Calls f three times with no arguments, collecting results into an array. Example
Print["Answer:", Sum <| Thrice[ReadInt]]
?? 12
?? 3
?? -4
?? Answer: 11Triples[[(*)] list] → [(*)] (list)
Returns all overlapping slices of size 3 in list. Example
Print[Triples[1:5]]
?? [[1, 2, 3], [2, 3, 4], [3, 4, 5]]Twice[fn f] → [(*)] (functional)
Calls f twice with no arguments, collecting results into an array. Example
Print[Twice[Prompt<~"> "~>]]
?? > hello
?? > world
?? ["hello", "world"]