AtFunctions.rb

Return to the index.

Table of Contents

Function count: 344

Click on genres to show all functions in that genre.

(class)Class, ClassNamed, New
(conversion)Char, F, N, String
(data)Hash, Pred, Succ, V
(functional)Agenda, Applier, Apply, Bond, C, Call, CallEach, CallN, Configurable, Configure, Curry, Fixpoint, Fork, GenerateFirst, GenerateN, GetOption, Hook, Id, InvocationIndex, Nest, NestList, NestListWhile, NestWhile, On, Periodic, PeriodicSteps, RBond, Series, SeriesIf, TakeWhile, Tie, TieArray
(functional/list)Fold, FoldList, FoldRight, FoldRightList, Over
(IO)AllInput, Arg, ClearScreen, Cls, Display, Exit, Option, Print, Prompt, ReadChar, ReadFloat, ReadInt, ReadLine, ReadLineLoop, ReadNumber, Stdin, Stdout, Wait
(IO/files)FileExists, FileRead, FileWrite
(list)Accumulate, Average, Bisect, Bounce, Chop, Chunk, Collapse, Complement, Concat, Count, Delta, Difference, Enumerate, Find, First, Flat, FlatGet, FlatGroup, Flip, Get, Grade, Group, Has, Index, IndexFlat, Indices, IndicesFlat, Integers, Intersection, Intersperse, Iota, Larger, Last, LastIndex, LastIndexFlat, List, Max, Median, Min, Outers, Pop, Positions, Powerset, Prefixes, Prod, Push, Range, Remove, RemoveAmong, RemoveFirst, RemoveLast, Repeat, Resize, Reverse, RLE, Rotate, Rotations, Same, Shift, Slices, SlicesFill, Sparse, StdDev, Suffixes, TriangleRange, TriangleSelect, Union, Unique, UniqueBy, Unshift, UnSparse
(list/logic)Decreasing, Increasing, Overlap, Palindromic
(list/matrix)ArrayFlatten, LowerTriangle, UpperTriangle
(list/random)Shuffle
(logic)All, And, Any, DoWhile, Falsey, ForEach, If, Invariant, Mask, Nand, None, Nor, Not, Or, Truthy, While, Xnor, Xor
(meta)Eval, EvalHere, Needs, Save
(numeric)Abs, Add, Cbrt, Ceiling, Digits, Divide, DivMod, Double, Exp, Floor, GCD, Halve, Im, IntLog, LCM, Ln, Log, Log2, LogBase, Multiply, PlusMinus, Rational, Re, Root, Round, Sign, Sqrt, Square, Subtract
(numeric/bases)Bin, FromBase, Hex, Oct, ToBase, UnBin, UnHex, UnOct
(numeric/logic)Even, Imaginary, Integral, IsImaginary, IsRational, IsSquare, Negative, Numeric, Odd, Positive, Real, Zero
(numeric/prime)IsComposite, IsPrime, NextPrime, PreviousPrime, Prime, PrimeDivision, PrimeFactors, PrimeNu, PrimeOmega, Primes
(numeric/random)Random, RNG
(numeric/rational)Denominator, Numerator
(numeric/series)Collatz, CollatzSize, Fibonacci, Polygonal, Pythagorean, Triangular
(numeric/trig)ArcCos, ArcCosh, ArcSin, ArcSinh, ArcTan, ArcTan2, ArcTanh, Cos, Cosh, Sin, Sinh, Tan, Tanh
(operator)%, *, +, -, ->, ., .., ..., /, //, :, ::, <|, ^, ^^, |>, ±, Ø, , , , , , , , , ,
(operator/logic)!in, /=, <, <=, =, =/=, ==, >, >=, |, , , , , , , , , and, else, in, is, is_a, is_an, is_not_a, is_not_an, nand, nor, not, or, xor
(scope)Clear, ClearLocal, Define, Local, Modify, Retrieve
(string)Center, Chars, Chomp, Downcase, FindHead, Format, Grid, Join, Lines, Ord, Ords, PadLeft, PadRight, Replace, ReplaceF, ReplaceMultiple, Rot, Split, Translate, Upcase
(string/HTML)HTMLEscape
(string/regex)Match, MatchAll
(unary operator)', not, parentof, typeof

((*) x) !in ([(*)] y) → bool (operator/logic)

Returns false if y contains x, otherwise true. See also: Has.

Example

Print[3 !in 1:5] ?? false Print[30 !in 1:5] ?? true
Try it online!

((*) a) % ((*) b) → (*) (operator)

Vectorizes.

Modulo.

' (fn func) → fn (unary operator)

Forces func to use parent scope.

Example

a .= 5 Call[{ a .= 3 }] Print[a] ?? 5 Call['{ a .= 93 }] Print[a] ?? 93
Try it online!

((*) a) * ((*) b) → (*) (operator)

Vectorizes.

Multiplication.

((*) a) + ((*) b) → (*) (operator)

Vectorizes.

Addition.

((*) a) - ((*) b) → (*) (operator)

Vectorizes.

Subtraction.

(expr key) -> ((*) value) → ConfigureValue (operator)

Returns a ConfigureValue key-value pair of key and value. Used for configurable functions and hashes.

((*) obj) . (raw prop) → (*) (operator)

Obtains the member in obj with prop as a key.

Note: this feature is not completely finished, and may have unintended behaviours, such as [1, 2, 3].size.

Example

ages := <~ john -> 32, bob -> 14, dude -> 92 ~> Print[ages.john] ?? 32 Person := Class! { name .= _1 age .= _2 } john := New[Person, "John Smith", 43] Print[john.name, john.age, joiner->", "]
Try it online!

(number x) .. (number y) → [number] (operator)

Vectorizes.

Returns a range from x to y, inclusive.

(number x) ... (number y) → [number] (operator)

Vectorizes.

Returns a range from x to y, excluding y.

(number a) / (number b) → number (operator)

Vectorizes.

Divides a by b. If a / b represents an integer, the argument becomes an integer. E.g., 4 / 2 is 2, not 2.0.

(number|fn a) // (number b) → rational (operator)

Vectorizes.

Creates a fraction a / b. See also: Rational

Arguments

fn a - Returns a function which, given e, returns Nest[a, e, b].

((*) x) /= ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x does not equal y, false otherwise. Note: does not call operator equality.

(number|fn x) : (number|fn y) → [number]|fn (operator)

Vectorizes.

Returns a range from x up to y. If x and y are both functions, returns a function f[...args] which calls x[...Map[y, args]].

Example

Print[3:6] ?? [3, 4, 5, 6] add_rev := Add:Reverse Print[add_rev[23, 45]] ?? 86
Try it online!

(number x) :: (number y) → [number] (operator)

Vectorizes.

Returns a range from x up to y. If x > y, returns a reversed range.

Example

Print[3::6] ?? [3, 4, 5, 6] Print[6::3] ?? [6, 5, 4, 3] Print[-3::-6] ?? [-3, -4, -5, -6]
Try it online!

((*) x) < ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is less than y, false otherwise.

((*) x) <= ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is less than or equal y, false otherwise.

(fn x) <| ((*) y) → (*) (operator)

Calls x with single parameter y.

((*) x) = ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x equals y, false otherwise.

((*) x) =/= ((*) y) → bool (operator/logic)

Returns true if x does not equal y, false otherwise.

((*) x) == ((*) y) → bool (operator/logic)

Returns true if x equals y, false otherwise.

((*) x) > ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is greater than y, false otherwise.

((*) x) >= ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is greater than or equal to y, false otherwise.

((*) a) ^ ((*) b) → (*) (operator)

Vectorizes.

Exponentiation.

([(*)]|fn a) ^^ ((*) b) → [(*)] (operator)

Removes all b from a. See also: Remove. If a is a fucntion, then folds a over b/

Example

Print[1:5 ^^ 2] ?? [1, 3, 4, 5] Print[[1, 2, 2, 3, 2, 4, 5, 3, 2, 1, 3] ^^ 2] ?? [1, 3, 4, 5, 3, 1, 3] Print[Add ^^ 1:5] ?? 15
Try it online!

((*) a) | (fn|(*) b) → (*) (operator/logic)

Vectorizes.

Returns true if a divides evenly into b.

Arguments

fn b - When b a function, calls b[a].

((*) x) |> (fn y) → (*) (operator)

Calls y with single parameter x.

((*) a) ± ((*) b) → (*) (operator)

Vectorizes.

Returns PlusMinus[a, b].

([(*)] a) Ø ([(*)] b) → [(*)] (operator)

Returns the a without all elements of b. See also: Complement.

(number x) ‥ (number y) → [number] (operator)

Vectorizes.

Returns a range from x to y, inclusive. See also: ...

(number x) … (number y) → [number] (operator)

Vectorizes.

Returns a range from x to y, excluding y. See also: ....

(number a) ⁄ (number b) → rational (operator)

Vectorizes.

Creates a fraction a / b. See also: Rational and //.

(expr key) → ((*) value) → ConfigureValue (operator)

Returns a ConfigureValue key-value pair of key and value. See also: ->.

([(*)] a) ∆ ([(*)] b) → [(*)] (operator)

Returns the symmetric difference between a and b.

((*) a) ∧ ((*) b) → bool (operator/logic)

Returns true if both of a and b are truthy, false otherwise. Short-circuits. See also: and.

((*) a) ∨ ((*) b) → (*) (operator/logic)

Returns a if a is truthy, b otherwise. Short-circuits. See also: or.

([(*)] a) ∩ ([(*)] b) → [(*)] (operator)

Returns the intersection of a and b.

([(*)] a) ∪ ([(*)] b) → [(*)] (operator)

Returns the union of a and b.

((*) x) ≠ ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x does not equal y, false otherwise. See also: /=.

((*) x) ≤ ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is less than or equal y, false otherwise. See also: <=.

((*) x) ≥ ((*) y) → bool (operator/logic)

Vectorizes.

Returns true if x is greater than or equal to y, false otherwise. See also: >=.

((*) a) ⊻ ((*) b) → bool (operator/logic)

Returns true if exactly one of a and b is truthy, false otherwise. See also: xor.

((*) a) ⊼ ((*) b) → bool (operator/logic)

Returns true if one of a and b are falsey, false otherwise. Short-circuits. See also: nand.

((*) a) ⊽ ((*) b) → bool (operator/logic)

Returns true if both of a and b are falsey, false otherwise. Short-circuits. See also: nor.

((*) x) ▷ (fn y) → (*) (operator)

Calls y with single parameter x. See also: |>.

(fn x) ◁ ((*) y) → (*) (operator)

Calls x with single parameter y. See also: <|.

([(*)] a) ⩓ ((*) b) → [(*)] (operator)

Removes all b from a. See also: a ^^ b.

Abs[number n] → number (numeric)

Vectorizes.

Calculates the absolute value of n.

Accumulate[[number] list] → [number] (list)

Generates the cumulative sums of list.

Add[number ...args] → number (numeric)

Adds each of args together.

Agenda[fn flist, fn[(*) -> number] cond, ...args] → fn[(*) -> (*)] (functional)

Curries.

Returns a function fn[...args] such that the cond[...args]th element of flist is called upon args.

Arguments

fn flist - A list of functions.

fn[(*) -> number] cond - A function which produces an index by which to obtain a function from flist.

Example

f := Agenda[ [Halve, {3 * _ + 1}], Odd] Print[Map[f, [1, 2, 3, 4]]] ?? [4, 1, 10, 2]
Try it online!

All[fn|[(*)] f, [(*)] list?] → bool (logic)

Returns true if all members of Map[f, list] are truthy.

Arguments

[(*)] list? - When omitted, returns true if all members of f are truthy. Otherwise, returns false. When specified, f must be a function.

AllInput[] → string (IO)

Reads all input from the instance's source input.

And[(*) a, (*) b] → bool (logic)

Logical conjunction. Returns true if both a and b are truthy, false otherwise.

Example

Print[TruthTrablePretty["And", 2]] ?? A | B | And[A, B] ?? ---+---+----------- ?? 0 | 0 | 0 ?? 0 | 1 | 0 ?? 1 | 0 | 0 ?? 1 | 1 | 1
Try it online!

((*) a) and ((*) b) → bool (operator/logic)

Returns true if both of a and b are truthy, false otherwise. Short-circuits.

Any[fn|[(*)] f, [(*)] list?] → bool (logic)

Returns true if any member of Map[f, list] is truthy.

Arguments

[(*)] list? - When omitted, returns true if any member of f is truthy. Otherwise, returns false. When specified, f must be a function.

Applier[fn func] → fn[[(*)]] (functional)

Returns a function fn[...args] which applies func to args.

Example

f := Applier[Print] f[1:5] Print[1, 2, 3, 4, 5] ?? 1 2 3 4 5
Try it online!

Apply[fn func, [(*)] arg_arr] → (*) (functional)

Calls func with arg_arr.

Example

args := [ Reverse, [ "hello", "world" ] ] Print[ Apply[Map, args] ] ?? ["olleh", "dlrow"]
Try it online!

ArcCos[number n] → number (numeric/trig)

Vectorizes.

Calculates cos-1(n).

ArcCosh[number n] → number (numeric/trig)

Vectorizes.

Calculates cosh-1(n).

ArcSin[number n] → number (numeric/trig)

Vectorizes.

Calculates sin-1(n).

ArcSinh[number n] → number (numeric/trig)

Vectorizes.

Calculates sinh-1(n).

ArcTan[number n] → number (numeric/trig)

Vectorizes.

Calculates tan-1(n).

ArcTan2[number y, number x] → number (numeric/trig)

Vectorizes.

Calculates the principal value of tan-1(y/x), or atan2(y, x).

ArcTanh[number n] → number (numeric/trig)

Vectorizes.

Calculates tanh-1(n).

Arg[number n=0] → string (IO)

Returns the nth argument given to the program.

ArrayFlatten[[[list]] list] → [list] (list/matrix)

Flattens the matrices held in the matrix-like list.

Example

m1 := [[1, 2], [3, 4]] m2 := [[0, 0], [7, 7]] Display[ArrayFlatten[ [[m1, m2, m1], [m2, m1, m2]] ]] ?? 1 2 0 0 1 2 ?? 3 4 7 7 3 4 ?? 0 0 1 2 0 0 ?? 7 7 3 4 7 7
Try it online!

Average[[number] list] → number (list)

Returns the average of list, that is, the sum of the elements divided by the length.

Bin[number n] → number (numeric/bases)

Vectorizes.

Converts n to base 2.

Bisect[[(*)] list, **opts] → [[(*)], [(*)]] (list)

Splits list in half.

Options

bias → what should be done with the center element, in the case of odd lists. "none": drop it (default). "left": append center to the left half. "right": append center to the right half.

Example

Print[Bisect[1:4]] ?? [[1, 2], [3, 4]] Print[Bisect[1:5]] ?? [[1, 2], [4, 5]] Print[Bisect[1:5, bias->$none]] ?? [[1, 2], [4, 5]] Print[Bisect[1:5, bias->$left]] ?? [[1, 2, 3], [4, 5]] Print[Bisect[1:5, bias->$right]] ?? [[1, 2], [3, 4, 5]]
Try it online!

Bond[fn func, (*) larg] → fn (functional)

Bonds larg to the left side of func. That is, Bond[func, larg][...args] is the same as func[larg, ...args].

Bounce[[(*)] list] → [(*)] (list)

Reforms result.

"Bounces" a list. That is, returns the list concatenated with itself reversed, where the last element of the original array is not duplicated in the concatenation. Inspiration: Jelly's ŒB monadic atom.

Example

Print[Bounce[1:3]] ?? [1, 2, 3, 2, 1] Print[Bounce["Hello"]] ?? HellolleH Print[Bounce[942]] ?? 94249
Try it online!

C[(*) arg] → fn (functional)

Returns a function that returns arg.

Call[fn f, (*) ...args] → (*) (functional)

Calls f over args.

Example

Call[Print, "Hello", "World"] ?? Hello World
Try it online!

CallEach[[fn] fs, (*) ...args] → (*) (functional)

Curries.

Vectorizes function calling over each function f in fs over args.

CallN[fn f, number n, (*) ...args] → (*) (functional)

Curries.

Calls f n times over args, storing the results in a list.

Example

rand := Configure[Random, RNG->RNG[10]] Print[CallN[Random, 4, 3, 10]] ?? [4, 8, 7, 10] Print[CallN[rand, 10, 0, 1]] ?? [1, 1, 0, 1, 0, 1, 1, 0, 1, 1]
Try it online!

Cbrt[number n] → number (numeric)

Vectorizes.

Returns the cube root of n.

Ceiling[number n, number r?] → number (numeric)

Vectorizes.

Returns n rounded up to the nearest integer.

Arguments

number r? - the precision to round. No precision if omitted.

Center[[(*)] ent, number amt, (*) pad?] → string (string)

Vectorizes.

Centers ent to amt elements, padding with pad.

Arguments

(*) pad? - Default: " " or 0, depending on ent.

Example

Print[Center["a", 3]] ?? " a " Print[Center[[1, 2], 6]] ?? [0, 0, 1, 2, 0, 0] Print[Center["Hi!", 10, "~"]] ?? "~~~Hi!~~~~" Print[Center[9, 5, 1]] ?? 11911
Try it online!

Char[number|[number] arg] → string (conversion)

Converts arg to characters.

Arguments

number arg - Converts arg to a character.

[number] arg - Converts arg to a string of char codes.

Chars[string str] → [string] (string)

Vectorizes.

Returns the characters of str.

Chomp[(*) ent, (*) to_chomp=NOT_PROVIDED] → (*) (string)

Removes to_chomp once from the end of ent.

Arguments

(*) to_chomp=NOT_PROVIDED - For strings, defaults to "\n"; otherwise, 0.

Chop[[(*)] list, size, **opts] → [[(*)]] (list)

Reforms result's elements.

Chops list into groups of length size.

Options

extra → Boolean: keeps elements which don't add up to size if true. Default: true.

Example

Print[Chop[1:8, 3]] ?? [[1, 2, 3], [4, 5, 6], [7, 8]] Print[Chop[1:8, 3], extra->false] ?? [[1, 2, 3], [4, 5, 6]] Print[Chop["Hello, World!", 3]] ?? ["Hel", "lo,", " Wo", "rld", "!"] Print[Chop[1:12, [1, 2, 3]]] ?? [[1], [2, 3], [4, 5, 6], [7], [8, 9], [10, 11, 12]]
Try it online!

Chunk[[(*)] list, fn f?] → [[(*), [(*)]]] (list)

Chunks list into runs of consecutive values. Returns an array of members which look like [el, els], where el is the principal run value, and els are the values in that run.

Arguments

fn f? - When specified, maps each value el in list over f, then uses f[el] as the principal run value.

Example

Print[Chunk[ [1, 2, 3, 2, 2, 3] ]] ?? [[1, [1]], [2, [2]], [3, [3]], [2, [2, 2]], [3, [3]]] Display[Chunk[ [1, -1, 1, 1, 2, 3, -3, 5, -2 ], Square ]] ?? 1 [1, -1, 1, 1] ?? 4 [2] ?? 9 [3, -3] ?? 25 [5] ?? 4 [-2]
Try it online!

Class[fn body, parent=nil] → class (class)

Creates an anonymous class.

Arguments

fn body - Any local definition made within constitutes a method or instance variable decleration.

ClassNamed[string name, parent=nil] → fn (class)

Creates a named class. Returns a function which acts similarly to Class.

Clear[string name] → (*) (scope)

Undefines name from the global scope. Returns that variable's value, or nil if the variable was undefined.

ClearLocal[string name] → (*) (scope)

Undefines name from the local scope. Returns that variable's value, or nil if the variable was undefined.

ClearScreen[] → nil (IO)

Clears the console's screen.

Cls[] → bool (IO)

Clears the console screen. Returns `true` if successful, `false` otherwise.

Collapse[[(*)] ...lists] → [(*)] (list)

Concatenates all the lists in lists, except for matching prefix-suffix pairs.

Collatz[number n] → [number] (numeric/series)

Vectorizes.

Produces the Collatz sequence of n.

CollatzSize[number n] → number (numeric/series)

Vectorizes.

Returns the number of steps it takes for n to reach 1 according to the Collatz transformation.

Complement[[(*)] parent, [(*)] ...args] → [(*)] (list)

Returns all elements of parent not included in any of the lists in args.

Concat[[(*)] ...args] → [(*)] (list)

Returns the concatentation of each list in args.

Example

Print[Concat[ 1:5, 2:3, [7], [[8, 9]] ]] ?? [1, 2, 3, 4, 5, 2, 3, 7, [8, 9]]
Try it online!

Configurable[fn f] → fn (functional)

Gives f access to any options passed to it, i.e. through GetOption.

Example

nameOf := Configurable { GetOption[$name] } Print[nameOf[name -> "John"]] ?? John Print[nameOf[]] ?? nil
Try it online!

Configure[fn func, **opts] → fn (functional)

Returns a function which calls func configured with opts.

Example

print_weird := Configure[ Print, joiner->", ", before->"{", after->"}\n" ] print_weird[3, 4, 5] ?? {3, 4, 5}
Try it online!

Cos[number n] → number (numeric/trig)

Vectorizes.

Calculates cos(n).

Cosh[number n] → number (numeric/trig)

Vectorizes.

Calculates cosh(n).

Count[fn|(*) f, [(*)] list] → number (list)

Curries.

Counts the number of members satisfying f in list; or, if f is not a function, the number of times f appears in list.

Curry[fn f, number arity?] → fn (functional)

Returns fn, fully curried according to arity.

Arguments

number arity? - Default: #f.

Example

add_dy := [x, y] -> { x + y } adder := Curry[add_dy] add3 := adder[3] Print[add3[5]] ?? 8 Print[adder[2][5]] ?? 7 add_tri := Curry[Add/3] adder1 := add_tri[1] add6 := adder1[5] Print[add6[10]] ?? 16
Try it online!

Decreasing[[(*)] list] → bool (list/logic)

Returns true if every element a which is followed by an element b is strictly greater than b.

Example

Print[Decreasing[ -(1:5) ]] ?? true Print[Decreasing[ [2, 1, 0] ]] ?? true Print[Decreasing[ [] ]] ?? true Print[Decreasing[ [2, 2, 1, 0] ]] ?? false Print[Decreasing[ 1:5 ]] ?? false
Try it online!

Define[string name, (*) value] → (*) (scope)

Defines name in the global scope as value. Returns value.

Example

Define[$a, "This is variable a!"] Print[a] ?? This is variable a!
Try it online!

Delta[[number] list] → [number] (list)

Returns the differences between each member of list.

Example

Print[Delta[ 1:4 ]] ?? [1, 1, 1] Print[Delta[ [] ]] ?? [] Print[Delta[ Square[0:4] ]] ?? [1, 3, 5, 7]
Try it online!

Denominator[number n] → number (numeric/rational)

Vectorizes.

Returns the numerator of n.

Difference[[(*)] a, [(*)] b] → [(*)] (list)

Returns all elements exclusive to a or b.

Digits[number n] → [number] (numeric)

Vectorizes.

Produces the digits of n.

Display[(*) ent] → (*) (IO)

Displays ent in a human-reversible format. Primarily, prints the elements of arrays (whose dimension is at least 2) on separate lines.

Example

Display[ [1:3, 4:6, 9:11] ] ?? 1 2 3 ?? 4 5 6 ?? 9 10 11 Display[ "Hello, World!" ] ?? "Hello, World!"
Try it online!

Divide[number ...args] → number (numeric)

Divides each number in args by the next. That is, folding division over args

DivMod[number d, number m] → [number, number] (numeric)

Vectorizes.

Simultaneously calculates division and modulus operations, returned as a pair.

Example

Print[DivMod[23, 2]] ?? [11, 1] Print[DivMod[5, 20]] ?? [0, 5]
Try it online!

Double[number n] → number (numeric)

Vectorizes.

Doubles n.

DoWhile[expression cond, expression body] → (*) (logic)

Evaluates body, then stops only if cond evaluates as falsey.

Example

i := 0 DoWhile[i < 5, Print[i]; i := i + 1] ?? 0 ?? 1 ?? 2 ?? 3 ?? 4 DoWhile[false, Print["Hello!"]] ?? Hello!
Try it online!

Downcase[string str] → string (string)

Vectorizes.

Replaces all uppercase letters in str with the respective lowercase one.

Example

Print[Downcase["Hello, World!"]] ?? hello, world! Print[Downcase[">>> NO ONE"]] ?? >>> no one Print[Downcase["le monde"]] ?? le monde
Try it online!

((*) a) else ((*) b) → bool (operator/logic)

Returns a if a is truthy, b otherwise. Short-circuits.

Enumerate[[(*)] list, start=0] → [[(*), number]] (list)

Returns a list of all elements in list paired with their indices, starting at offset.

Eval[string str] → (*) (meta)

Evaluates str in a new scope. Returns the last expression evaluated.

EvalHere[string str, blanks=[]] → (*) (meta)

Evaluates str in a the current scope. Returns the last expression evaluated.

Even[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n is even (a multiple of 2), otherwise false.

Exit[number code?] → nil (IO)

Terminates the program with exit code 0. Flushes STDOUT.

Arguments

number code? - the code to exit with.

Exp[number n] → number (numeric)

Vectorizes.

Calculates en.

F[BigDecimal|complex|(*) ent] → number (conversion)

Converts ent to a floating-point number.

Arguments

BigDecimal ent - Obtains the floating point value of ent.

complex ent - Forces each component of ent to be a floating point number.

(*) ent - Calls N[ent], then converts to that float.

Falsey[(*) arg] → bool (logic)

Returns true if arg is falsey, false otherwise. (See also: Not.)

Fibonacci[number n] → number (numeric/series)

Vectorizes.

Returns the nth number in the Fibonacci sequence, starting with f0 = 0 and f1 = 1.

FileExists[string name] → bool (IO/files)

Returns true if name represents a valid file, false otherwise.

FileRead[string name, **opts] → string (IO/files)

Returns the contents of file name, or nil if the file does not exist.

Options

encoding → The encoding that the target file is in.

FileWrite[string name, string content, **opts] → number (IO/files)

Writes content to file name. Returns the number of bytes written.

Options

encoding → The encoding that the target file is in.

Find[fn|(*) f, [(*)] list] → (*) (list)

Returns the first element e in list which satisfies f. Returns nil otherwise.

Arguments

fn f - applied to each successive member of list until a truthy value is obtained.

(*) f - returns the first element in list equal to f.

FindHead[[string]|{string->(*)} opts, string val] → string (string)

Selects the first key (or value) in opts which start with val.

Example

names := ["John", "James", "Mary"] Print[FindHead[names, "J"]] ?? John Print[FindHead[names, "Ja"]] ?? James Print[FindHead[names, "M"]] ?? Mary Print[nil = FindHead[names, "Z"]] ?? true options := <~ stop -> 0, continue -> 1, redo -> 2 ~> choice := "s" Print[FindHead[options, choice]] ?? stop
Try it online!

First[[(*)] list] → (*) (list)

Returns the first element of list.

Example

Print[First[ [3, 9, 2, 0] ]] ?? 3 Print[First[ "Hello!" ]] ?? H
Try it online!

Fixpoint[fn f, (*) n] → (*) (functional)

Curries.

Applies f to n until f[n] converges.

Flat[[(*)] list, number n?] → [(*)] (list)

Flattens list.

Arguments

number n? - when specified, flattens list to 1 level n times.

FlatGet[[(*)] list, [(*)]|(*) inds] → (*) (list)

Returns list[i0][i1]...[iN] for each i in inds.

Example

id := Identity[3] Display[id] ?? 1 0 0 ?? 0 1 0 ?? 0 0 1 Print[FlatGet[id, 0]] ?? [1, 0, 0] Print[FlatGet[id, [0]]] ?? [1, 0, 0] Print[FlatGet[id, [0, 0]]] ?? 1
Try it online!

FlatGroup[fn f, [(*)] list, (*) fill?] → [(*)] (list)

Curries.

Equivalent to UnSparse@Group.

Flip[[(*)] list] → [(*)] (list)

Reforms result.

Reverses and transposes a list, or, if the list has only one dimension, reverses it.

Floor[number n, number r?] → number (numeric)

Vectorizes.

Returns n rounded down to the nearest integer.

Arguments

number r? - the precision to round. No precision if omitted.

Fold[fn f, [(*)] list, (*) start?] → (*) (functional/list)

Curries.

Folds the function f over the list list, optionally starting with start.

Example

Print[Fold[${ x + y }, [2, 3, 6, 7]]] ?? 18 Print[Fold[${ $"f[${x}, ${y}]" }, 1:5]] ?? f[f[f[f[1, 2], 3], 4], 5] Print[Fold[Add, 123]] ?? 6 Print[Fold[${ y + x }, "Hello, World!"]] ?? !dlroW ,olleH Print[Fold[Add, [1]]] ?? 1 Display[Fold[Add, []]] ?? nil Display[Fold[Add, [], 0]] ?? 0
Try it online!

FoldList[fn f, [(*)] ent, (*) start?] → [(*)] (functional/list)

Curries.

Cumulatively folds the function f over ent, optionally starting at start.

FoldRight[fn f, [(*)] list, (*) start?] → (*) (functional/list)

Curries.

Folds the function f over the list list, optionally starting with start.

Example

Print[Fold[${ x + y }, [2, 3, 6, 7]]] ?? 18 Print[Fold[${ $"f[${x}, ${y}]" }, 1:5]] ?? f[f[f[f[1, 2], 3], 4], 5] Print[Fold[Add, 123]] ?? 6 Print[Fold[${ y + x }, "Hello, World!"]] ?? !dlroW ,olleH Print[Fold[Add, [1]]] ?? 1 Display[Fold[Add, []]] ?? nil Display[Fold[Add, [], 0]] ?? 0
Try it online!

FoldRightList[fn f, [(*)] ent, (*) start?] → [(*)] (functional/list)

Curries.

Cumulatively folds the function f over ent from the right, optionally starting at start.

ForEach[[(*)] ent, body] → nil (logic)

For every value el in ent, evaluates body, setting the first abstract value to el, and the second to its index.

Fork[fn f, fn g, fn h] → fn (functional)

Composes the functions f, g, and h into a fork. When called with arguments args, this is equivalent to calling g[f[...args], h[...args]].

Example

avg := Fork[Sum, Divide, Size] Print[avg[1:5]] ?? 3.0
Try it online!

Format[string str, (*) ...args] → string (string)

Formats a string. Currently, uses Ruby's % method on strings.

Example

Print[Format["%s is a %s", "Java", "Joke"]] ?? Java is a Joke
Try it online!

FromBase[[number] num, number base] → number (numeric/bases)

Vectorizes.

Converts num from base base to base 10.

Arguments

[number] num - an array of digits representing the number in base base.

number base - a number greater than 0, representing the source base of the numeric array.

GCD[number ...args] → number (numeric)

Takes the Greatest Common Divisor of the atoms of args.

Arguments

number ...args - List of numbers, which can have nested elements.

GenerateFirst[fn f, fn cond, number start?] → (*) (functional)

Starting at n = start, increments n until cond[f[n]] is truthy. Returns f[n]. Note: this ignores nil values returned.

Arguments

fn f - A function that maps a number to a domain, such as Square or Prime.

fn cond - A function which, given a possible result of f, returns a truthy or falsey value.

number start? - The starting point for testing numbers.

GenerateN[fn f, fn cond, number size, number start?] → (*) (functional)

Similar to GenerateFirst, returns the first size values of f satisfying cond

Arguments

fn f - A function that maps a number to a domain, such as Square or Prime.

fn cond - A function which, given a possible result of f, returns a truthy or falsey value.

number start? - The starting point for testing numbers.

Get[[(*)] list, number|ConfigureValue ind] → [(*)]|string (list)

Vectorizes.

Gets all members at indices inds from list.

Arguments

ConfigureValue ind - Returns the members between the key and the value. If the value is negative, starts at the respective index from the right. Returns a string if given a string, instead of an array of characters.

Example

Print[Get[1:5, 2]] ?? 3 Print[Get["Hello, World!", 0:4]] ?? ["H", "e", "l", "l", "o"] Print[Get["Hello, World!", 4 -> -4]]
Try it online!

GetOption[string name, (*) ...others] → (*) (functional)

Gives the function easy access to the OPTIONS variable, if defined. If the requested option was not passed, the first non-nil element in others will be returned, if any.

Example

calibrate := Configurable { sens .= GetOption[$sensitivity, 0.01] If[_ <= sens, "no reading", $"reading: ${_ * sens}" ] } Print[calibrate[5]] ?? reading: 0.05 Print[calibrate[5, sensitivity->100]] ?? no reading
Try it online!

Grade[[(*)] list] → [number] (list)

Returns a list of indices such that, when list is indexed by that list, the result is list sorted.

Grid[string str, string inner?] → string (string)

Returns the characters of each line of str.

Arguments

string inner? - Character to pad the ends of each line with. Default: " ".

Example

Map[Print, Grid["Hello,\nWorld\nof mine!"]] ?? ["H", "e", "l", "l", "o", ",", " ", " "] ?? ["W", "o", "r", "l", "d", " ", " ", " "] ?? ["o", "f", " ", "m", "i", "n", "e", "!"]
Try it online!

Group[fn f, [(*)] list] → Hash[(*) -> (*)] (list)

Curries.

Groups list according to Map[fn, list].

Halve[number n] → number (numeric)

Vectorizes.

Takes half of n.

Has[[(*)]|string list, (*) member] → bool (list)

Returns true if list contains member, false otherwise.

Arguments

string list - returns if member is contained within list.

Hash[ConfigureValue ...opts] → Hash[string -> (*)] (data)

Creates a hash.

Arguments

ConfigureValue ...opts - A series of value pairs a -> v.

Hex[number n] → number (numeric/bases)

Vectorizes.

Converts n to base 16.

Hook[fn f, fn g] → fn (functional)

Composes the functions f and g into a hook. When called with arguments args this is equivalent to calling f[First[args], g[...args]].

HTMLEscape[string str] → string (string/HTML)

Escapes str such that it is safe to be passed to an HTML document. (Escapes the following: &<>".)

Id[(*) a] → (*) (functional)

Identity function; returns its argument.

If[(*) cond, expression t, expression f?] → (*) (logic)

If cond is truthy, evaluates t. Otherwise, if f is specified, evaluates f.

Example

If[3 = 4, Print["Logic does not hold!"], Print["Everything is situation normal."] ]
Try it online!

Im[(*) n] → number (numeric)

Vectorizes.

Returns the imaginary part of n, or 0 if it doesn't exist.

Imaginary[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n = a+bi for b /= 0, otherwise false.

((*) x) in ([(*)] y) → bool (operator/logic)

Returns true if y contains x, otherwise false. See also: Has.

Example

Print[3 in 1:5] ?? true Print[30 in 1:5] ?? false
Try it online!

Increasing[[(*)] list] → bool (list/logic)

Returns true if each member el is strictly greater than the previous element, otherwise false.

Index[[(*)] list, (*) ind] → number (list)

Vectorizes.

Returns the index of the first occurrence of ind in list.

IndexFlat[[(*)] list, (*) ind] → number (list)

Returns the index of the first occurrence of ind in list.

Indices[[(*)] list, (*) ind] → [number] (list)

Vectorizes.

Returns all indices at which ind occurs in list.

Example

Print[Indices[ [1, 1, 2, 3, 1, 3, 1], [1, 3] ]] ?? [[0, 1, 4, 6], [3, 5]]
Try it online!

IndicesFlat[[(*)] list, (*) ind] → [number] (list)

Returns all indices at which ind occurs in list.

Example

Print[IndicesFlat[ [1, 1, 2, 3, 1, 3, 1], [1, 3] ]] ?? []
Try it online!

Integers[...args] → [(*)] (list)

Returns the first Prod[Size => args] non-negative integers.

Integral[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n represents an integer, otherwise false.

Intersection[[(*)] ...lists] → [(*)] (list)

Returns the intersection of the arguments.

Intersperse[[(*)] list, (*) joiner] → [(*)] (list)

Returns a list where joiner is placed in between each element of list.

Example

Print[Intersperse[1:3, 0]] ?? [1, 0, 2, 0, 3]
Try it online!

IntLog[number n, base] → number (numeric)

Vectorizes.

Calculates the discrete logarithm of n mod base.

Invariant[fn func, (*) arg?] → bool (logic)

Determines whether or not arg = func[arg]

Arguments

(*) arg? - when omitted, returns a function f[x] = Invariant[func, x].

InvocationIndex[fn func] → fn (functional)

Given a function func, returns a function which calls func with an additional argument representing the number of times func has been invoked.

Iota[[(*)]|number min] → [(*)] (list)

Returns an range from 0 (inclusive) to min or the length of min as applicable (exclusive).

Example

Print[Iota[5]] ?? [0, 1, 2, 3, 4] Print[Iota["Hi!"]] ?? [0, 1, 2]
Try it online!

((*) x) is ((*) y) → bool (operator/logic)

Synonym for ==.

((*) el) is_a (class klass) → bool (operator/logic)

Returns true if el is an instance of klass, otherwise false.

((*) el) is_an (class klass) → bool (operator/logic)

Returns true if el is an instance of klass, otherwise false.

((*) el) is_not_a (class klass) → bool (operator/logic)

Returns false if el is an instance of klass, otherwise true.

((*) el) is_not_an (class klass) → bool (operator/logic)

Returns false if el is an instance of klass, otherwise true.

IsComposite[number n] → bool (numeric/prime)

Vectorizes.

Returns true if n is composite (not prime), and false otherwise.

IsImaginary[number n] → bool (numeric/logic)

Returns true if n = a+bi for b /= 0, otherwise false.

IsPrime[number n] → bool (numeric/prime)

Vectorizes.

Returns true if n is prime, and false otherwise.

IsRational[(*) x] → bool (numeric/logic)

Returns true is n is a Rational, false otherwise.

IsSquare[number n] → bool (numeric/logic)

Returns true if n is a perfect square (i.e. expressable as an integer multiplied by itself), otherwise false.

Join[[(*)] list, string joiner?] → string (string)

Vectorizes.

Joins list by joiner.

Larger[[(*)] a, [(*)] b] → (*) (list)

Vectorizes.

Returns the larger of a and b. Similar to Max, except Larger vectorizes.

Example

Print[Larger[1, 5]] ?? 5 Print[Larger[[1, 2, 3], [3, 2, 1]]] ?? [3, 2, 3]
Try it online!

Last[[(*)]|string list] → (*) (list)

Returns the last member of list.

Example

Print[Last["hiya"]] ?? a Print[Last[1:5]] ?? 5
Try it online!

LastIndex[[(*)] list, (*) ind] → number (list)

Vectorizes.

Returns the index of the last occurrence of ind in list.

LastIndexFlat[[(*)] list, (*) ind] → number (list)

Returns the index of the last occurrence of ind in list.

LCM[number ...args] → number (numeric)

Takes the Least Common Multiple of the atoms of args.

Arguments

number ...args - List of numbers, which can have nested elements.

Lines[string str] → [string] (string)

Vectorizes.

Returns all lines of str; splits on line breaks, which are newlines preceeded by an optional carriage reutrn.

Example

Print[Lines["abc\nhello"]] ?? ["abc", "hello"]
Try it online!

List[(*) ent] → [(*)] (list)

Forces ent into a list.

Arguments

number ent - Returns the digits of ent.

string ent - Returns the characters of ent.

hash ent - Returns an array of key-value pairs in ent.

Ln[number n] → number (numeric)

Vectorizes.

Takes the natural logarithm of n. Note that ln(n)=loge(n).

Local[string name, (*) value] → (*) (scope)

Defines name in the local scope as value. Returns value.

Log[number n] → number (numeric)

Vectorizes.

Takes the base-10 logarithm of n.

Log2[number n] → number (numeric)

Vectorizes.

Takes the base-2 logarithm of n.

LogBase[number n, b] → number (numeric)

Vectorizes.

Takes the base-b logarithm of n.

LowerTriangle[[[(*)]] mat, bool strict?] → [[(*)]] (list/matrix)

Returns the lower triangle of mat, where the remaining values are replaced with zeroes.

Arguments

bool strict? - If true, includes the diagonal. Default: true.

Example

mat := Integers[3, 3] + 1 Display[mat] ?? 1 2 3 ?? 4 5 6 ?? 7 8 9 Display[LowerTriangle[mat]] ?? 1 0 0 ?? 4 5 0 ?? 7 8 9 Display[LowerTriangle[mat, true]] ?? 0 0 0 ?? 4 0 0 ?? 7 8 0
Try it online!

Mask[[(*)] mask, [(*)] list] → [(*)] (logic)

Reforms result.

Selects all elements el in list whose respective member in mask is truthy.

Example

Print[Mask[ [true, false, true, true, false], 1:5]] ?? [1, 3, 4]
Try it online!

Match[string source, (*) match] → string (string/regex)

Vectorizes.

Matches first occurrence of match (cast to regex) in source. If only one argument source is given, then returns a function which takes the source as input.

Example

Print[Match["no you?", ".{3}"]] ?? "no " Print[Match["cat in the hat", "[ch]at"]] ?? "cat" match2vowels := Match[`"\w*[aeiou]{2}\w*"] Print[match2vowels["Hello, loopy man!"]] ?? "loopy"
Try it online!

MatchAll[string source, (*) match] → [(*)] (string/regex)

Vectorizes.

Matches all occurrences of match in source.

Example

Print[MatchAll["no you?", ".{3}"]] ?? ["no ", "you"] Print[MatchAll["cat in the hat", "[ch]at"]] ?? ["cat", "hat"] match2vowels := MatchAll[`"\w*[aeiou]{2}\w*"] Print[match2vowels["Hello, loopy man!"]] ?? ["loopy"]
Try it online!

Max[(*) ...args] → (*) (list)

Returns the largest element contained in any atom of args.

Median[[number] list] → number (list)

Returns the median of list.

Example

Print[Median[[1, 2, 3]]] ?? 2 Print[Median[[1, 2, 3, 4]]] ?? 2.5
Try it online!

Min[(*) ...args] → (*) (list)

Returns the smallest element contained in any atom of args.

Modify[string head, expression body] → (*) (scope)

Modifies head according to body.

Arguments

expression body - an expression using the first abstract variable _ to represent the original value.

Example

a := 3 Modify[$a, _ * 2 + 1] Print[a] ?? 7
Try it online!

Multiply[number ...args] → number (numeric)

Takes the product of the elements of args.

N[[number]|string|number|(*) ent] → number (conversion)

Converts ent to an number.

Arguments

[number] ent - Converts ent to base 10.

string ent - Parses ent as a base 10 integer.

number ent - Converts ent to an integer if it represents one.

(*) ent - Attempts to cast ent to an integer.

Nand[(*) a, (*) b] → bool (logic)

Logical alternative denial. Returns true if at least one of a and b are falsey, false otherwise.

Example

Print[TruthTrablePretty["Nand", 2]] ?? A | B | Nand[A, B] ?? ---+---+------------ ?? 0 | 0 | 1 ?? 0 | 1 | 1 ?? 1 | 0 | 1 ?? 1 | 1 | 0
Try it online!

((*) a) nand ((*) b) → bool (operator/logic)

Returns true if one of a and b are falsey, false otherwise. Short-circuits.

Needs[string ...libs] → [string] (meta)

Imports libraries. Returns list of libaries' names included.

Arguments

string ...libs - list of strings corresponding to library names.

Negative[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n is less than 0, otherwise false.

Nest[fn f, init, number n] → (*) (functional)

Applies f to init n times.

Example

Print[Nest[Double, 1, 3]] ?? 8 (= 2 ^ 3)
Try it online!

NestList[fn f, init, number n, **opts] → (*) (functional)

Applies f to init n times, keeping the intermediate results.

Options

first → Specifies whether or not to include the first element. Default: true.

Example

Print[NestList[Double, 1, 3]] ?? [1, 2, 4, 8] Print[NestList[Double, 1, 3, first->false]] ?? [2, 4, 8]
Try it online!

NestListWhile[fn f, fn cond, (*) init, **opts] → (*) (functional)

Applies f to init until cond[init] is truthy.

Options

first → whether or not the input element init is included as the first element in the results. Default: true.

Example

Print[NestListWhile[Halve, Even, 100]] ?? [100, 50, 25]
Try it online!

NestWhile[fn f, fn cond, (*) init] → (*) (functional)

Curries.

Applies f to init until cond[init] is truthy.

Example

Print[NestWhile[Halve, Even, 100]] ?? 25
Try it online!

New[class ac, (*) ...args] → class[] (class)

Instantiates a class with parameters args.

NextPrime[number n, number rep?] → number (numeric/prime)

Vectorizes.

Returns the next prime greater than n.

Arguments

number rep? - When specified, returns the repth prime after n.

None[fn|[(*)] f, [(*)] list?] → bool (logic)

Returns Not[Any[...]].

Arguments

[(*)] list? - When omitted, returns true if any member of f is truthy. Otherwise, returns false. When specified, f must be a function.

((*) a) nor ((*) b) → bool (operator/logic)

Returns true if both of a and b are falsey, false otherwise. Short-circuits.

Nor[(*) a, (*) b] → bool (logic)

Logical joint denial. Returns true if at both a and b are falsey, false otherwise.

Example

Print[TruthTrablePretty["Nor", 2]] ?? A | B | Nor[A, B] ?? ---+---+----------- ?? 0 | 0 | 1 ?? 0 | 1 | 0 ?? 1 | 0 | 0 ?? 1 | 1 | 0
Try it online!

not ((*) arg) → bool (unary operator)

Returns false if b is truthy, true otherwise.

Not[(*) arg] → bool (logic)

Returns true if arg is falsey, false otherwise. (See also: Falsey.)

((*) a) not ((*) b) → bool (operator/logic)

Returns false if b is truthy, a otherwise.

Example

even_nonpos := { Even[_] not Positive[_] } Print[Select[even_nonpos, [-4, -3, -2, 0, 2, 3, 4]]] ?? [-4, -2, 0]
Try it online!

Numerator[number n] → number (numeric/rational)

Vectorizes.

Returns the numerator of n.

Numeric[number n] → bool (numeric/logic)

Returns true if n is a numeric value, otherwise false.

Oct[number n] → number (numeric/bases)

Vectorizes.

Converts n to base 8.

Odd[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n is odd (not a multiple of 2), otherwise false.

On[fn|[number] cond, fn f, [(*)] arr] → [number] (functional)

Curries.

Applies f to indices of arr, selected by cond.

Arguments

fn cond - If the given index yields true over cond, then the respective element is mapped to f.

[number] cond - If the given index is a member of cond.

Example

on_second := On[Odd] rev_second := on_second[Reverse] Print[rev_second[[ [1, 2, 3], [4, 5, 6], ["a", "b", "c"], ["d", "e", "f"] ]]] ?? [[1, 2, 3], [6, 5, 4], ["a", "b", "c"], ["f", "e", "d"]]
Try it online!

Option[string prompt, **opts] → string (IO)

Prints prompt and waits for character input found in opts.

Example

input := Option["Press something!", s -> "stop this program", i -> "print info", h -> "print hello world" ] ?? outputs "Press something!" ?? user presses the `i` key Print["Received:", Repr[input]] ?? Received: "i"
Try it online!

Or[(*) a, (*) b] → bool (logic)

Logical disjunction. Returns true if at least one of a and b are truthy, false otherwise.

Example

Print[TruthTrablePretty["Or", 2]] ?? A | B | Or[A, B] ?? ---+---+---------- ?? 0 | 0 | 0 ?? 0 | 1 | 1 ?? 1 | 0 | 1 ?? 1 | 1 | 1
Try it online!

((*) a) or ((*) b) → (*) (operator/logic)

Returns a if a is truthy, b otherwise. Short-circuits.

Ord[string|number ent, number offset?] → number (string)

Vectorizes.

Returns the UTF-8 ordinal representing ent.

Arguments

number offset? - Specifies the offset at which the ordinal is taken.

Example

Print[Ord["A"]] ?? 65 Print[Ord["asdf"]] ?? 97 Print[Ord["asdf", 1]] ?? 115 Print[Ord["asdf", 1:3]] ?? [115, 100, 102] Print[Ord[33]] ?? 33
Try it online!

Ords[string|number ent] → [number] (string)

Vectorizes.

Maps Ord over the characters of ent if it is a string; otherwise, is equivalent to [Ord[ent]].

Example

Print[Ords["Hello!"]] ?? [72, 101, 108, 108, 111, 33] Print[Ords[ [33, 34, 35] ]] ?? [32, 34, 35]
Try it online!

Outers[[(*)] list, number n?] → [(*)] (list)

Vectorizes.

Returns the outermost n elements from the left and right sides of list.

Arguments

number n? - Default: 1

Example

Print[Outers[1:5]] ?? [1, 5] Print[Outers[1:5, 2]] ?? [1, 2, 4, 5]
Try it online!

Over[ConfigureValue ...opts] → fn (functional/list)

Returns a function that will, over each element of its input list, select the first appropriate condition (if any) defined in opts and apply it to each element. Each key is a condition, and each value is a function to apply on elements satisfying that condition.

Example

squareFirst := Over[0 -> Square] Print[squareFirst[3:6]] ?? [9, 4, 5, 6] squareOddIndices := Over[Odd -> Square] Print[squareOddIndices[2:6]] ?? [2, 9, 4, 25, 6] zeroOutEvenIndices := Over[Even -> 0] Print[zeroOutEvenIndices[1:5]] ?? [0, 2, 0, 4, 0] oddEvenPulse := Over[Odd -> Succ, Even -> Pred] Print[oddEvenPulse[1:5]] ?? [0, 3, 2, 5, 4] named[x] := x = 0 or x = 2 negateNamed := Over[$named -> { -_ }] Print[negateNamed[1:5]] ?? [-1, 2, -3, 4, 5] named[x] := x /= 0 Print[negateNamed[1:5]] ?? [-1, 2, -3, 4, 5]
Try it online!

Overlap[[(*)] list, [(*)] search] → bool (list/logic)

Returns true if search exists as a contiguous subset in list, otherwise false.

PadLeft[(*) ent, number amt, (*) fill?] → (*) (string)

Pads ent to be no less than length amt, padding with fill elements fill on the left.

Arguments

string ent - appends space characters to the left of ent.

[(*)] ent - appends 0s to the left of ent.

Example

Display[PadLeft["Charles", 20]] ?? " Charles" Print[PadLeft[1:3, 6]] ?? [0, 0, 0, 1, 2, 3]
Try it online!

PadRight[(*) ent, number amt, (*) fill?] → (*) (string)

Pads ent to be no less than length amt, padding with fill elements fill on the right.

Arguments

string ent - appends space characters to the right of ent.

[(*)] ent - appends 0s to the right of ent.

Example

Display[PadRight["Charles", 20]] ?? "Charles " Print[PadRight[1:3, 6]] ?? [1, 2, 3, 0, 0, 0]
Try it online!

Palindromic[[(*)]|string ent] → bool (list/logic)

Determines if ent is palindromic, that is, if it is itself reversed.

parentof ((*) el) → class|nil (unary operator)

Returns the parent class of el, or nil if it doesn't exist.

Periodic[fn f, x] → fn (functional)

Curries.

Returns a function which, given (*) x, applies f to x until a result occurs twice, then returns the final result.

Example

dig_root := Periodic[Sum@Digits] Print[dig_root[1853]] ?? 8
Try it online!

PeriodicSteps[fn f, x] → fn (functional)

Curries.

Returns a function which, given (*) x, applies f to x until a result occurs twice, then returns the list of intermediate steps.

Example

dig_root_steps := PeriodicSteps[Sum@Digits] Print[dig_root_steps[1853]] ?? [1853, 17, 8, 8]
Try it online!

PlusMinus[number a, number b] → [number] (numeric)

Vectorizes.

Returns [a - b, a + b].

Polygonal[number n, number order=3] → number (numeric/series)

Vectorizes.

Obtains the nth order-agonal number.

Example

(* The triangular numbers (default) *) Print[Polygonal[0:5, 3]] ?? [0, 1, 3, 6, 10, 15] Print[Polygonal[0:5]] ?? [0, 1, 3, 6, 10, 15] (* The square numbers *) Print[Polygonal[0:5, 4]] ?? [0, 1, 4, 9, 16, 25]
Try it online!

Pop[[(*)] list, count=nil] → (*) (list)

Pops a member from the end of list, modifying it. Returns that element.

Positions[[(*)] arr, [(*)] els?] → [(*), [(*)]] (list)

Returns a list of lists of the form [id, inds], where id corresponds to a unique element of els. inds is a narray of indices where id occurs.

Arguments

[(*)] els? - Default: arr.

Example

Display[Positions[ [1, 2, 3, 2, 4, 1] ]] 1 [0, 5] 2 [1, 3] 3 [2] 4 [4] Display[Positions["Hello!", ["l", "!"]]] "l" [2, 3] "!" [5]
Try it online!

Positive[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n is greater than 0, otherwise false.

Powerset[[(*)] list] → [[(*)]] (list)

Reforms result's elements.

Returns the powerset of list.

Example

Print[Powerset[ [9,4,6] ]] ?? [[], [9], [4], [9, 4], [6], [9, 6], [4, 6], [9, 4, 6]] Print[Powerset[123]] ?? [0, 1, 2, 12, 3, 13, 23, 123]
Try it online!

Pred[(*) ent] → (*) (data)

Returns the successor of ent.

Prefixes[[(*)] list] → [[(*)]] (list)

Reforms result's elements.

Returns the non-empty prefixes of list.

Example

Print[Prefixes[1:5]] ?? [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5]] Print[Prefixes["hi?"]] ?? ["h", "hi", "hi?"] Print[Prefixes[901]] ?? [9, 90, 901]
Try it online!

PreviousPrime[number n, number rep?] → number (numeric/prime)

Vectorizes.

Returns the closest previous prime before n.

Arguments

number rep? - When specified, returns the repth prime before n.

Prime[number n] → number (numeric/prime)

Vectorizes.

Returns the nth prime, starting at Prime[1] = 2.

Example

Print[Prime[1:10]]
Try it online!

PrimeDivision[number n] → [[number, number]] (numeric/prime)

Vectorizes.

Returns a list of the prime exponents of n. That is, a list of base-exponent pairs [[p1, e1], ..., [pN, eN]] such that pk and n=1k<npkek.

PrimeFactors[number n] → [number] (numeric/prime)

Vectorizes.

Returns a list of the prime factors of n with duplicates.

PrimeNu[number n] → number (numeric/prime)

Vectorizes.

Returns the number of unique prime factors of n.

PrimeOmega[number n] → number (numeric/prime)

Vectorizes.

Returns the number of prime factors of n.

Primes[number n] → [number] (numeric/prime)

Vectorizes.

Returns a list of the first n primes.

Print[(*) ...args, **opts] → [(*)] (IO)

Prints each argument of args, separated by spaces.

Options

after → String printed after everything else. Default: "\n".

before → String printed before everything else. Default: "".

joiner → The string which joins args. Default: " ".

Prod[[number] list] → number (list)

Returns the product of all members of list.

Prompt[string prompt?] → string (IO)

Prompts for a line of input. Returns string without trailing newline.

Arguments

string prompt? - String to display before input text. Nothing if omitted.

Push[[(*)] list, (*) ...args] → [(*)] (list)

Pushes args to the end of list, modifying it. Returns list.

Pythagorean[number n] → [number] (numeric/series)

Vectorizes.

Returns the nth enumeration of the Pythagorean triples.

Example

Print => Pythagorean[0:10] ?? [3, 4, 5] ?? [8, 6, 10] ?? [5, 12, 13] ?? [15, 8, 17] ?? [12, 16, 20] ?? [7, 24, 25] ?? [24, 10, 26] ?? [21, 20, 29] ?? [16, 30, 34] ?? [9, 40, 41] ?? [35, 12, 37]
Try it online!

Random[...args, **opts] → number (numeric/random)

Returns a pseudo-random number. By default, returns a random float between 0 (inclusive) and 1 (exclusive).

Arguments

- If m is omitted, returns a random integer between 0 (inclusive) and n (exclusive).

- When provided, returns a random integer between n and m, inclusive.

Range[number|string min, number|string max?] → [number|string] (list)

Vectorizes.

Returns a range from min to max inclusive.

Arguments

number|string max? - If omitted, returns Range[0, min].

Example

Print[Range[1, 5]] ?? [1, 2, 3, 4, 5] Print[Range["a", "d"]] ?? ["a", "b", "c", "d"]
Try it online!

Rational[number a, number b] → rational (numeric)

Vectorizes.

Returns a fraction representing a / b.

RBond[fn func, (*) rarg] → fn (functional)

Bonds larg to the right side of func. That is, Bond[func, rarg][...args] is the same as func[...args, rarg].

Re[(*) n] → number (numeric)

Vectorizes.

Returns the imaginary part of n, or n if it doesn't exist.

ReadChar[] → string (IO)

Reads a character from the input.

ReadFloat[] → number (IO)

Reads a float from the input.

ReadInt[] → number (IO)

Reads an integer from the input.

ReadLine[] → string (IO)

Reads a line of input, to include any trailing newline.

ReadLineLoop[(*) ...args, fn[string -> string] func] → [string] (IO)

Iterates func over lines of stdin received by Prompt[...args]. Returns a list of these lines modified by func.

Arguments

fn[string -> string] func - A function that receives lines of input and returns a string.

ReadNumber[] → number (IO)

Reads a number from the input.

Real[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n has no imaginary part, otherwise false.

Remove[[(*)] list, (*) ent] → [(*)] (list)

Reforms result.

Returns list without any instances of ent.

Example

Print[Remove[1:5, 3]] ?? [1, 2, 4, 5] Print[Remove["Hello, World!", "l"]] ?? "Heo, Word!" Print[Remove["Hello, World!", "ll"]] ?? "Hello, World!"
Try it online!

RemoveAmong[[(*)] list, [(*)] ents] → [(*)] (list)

Reforms result.

Returns list without any of the elements specified by ents.

Example

Print[RemoveAmong[1:9, 4:7]] ?? [1, 2, 3, 8, 9] Print[RemoveAmong["Hello, World!", $A:$Z]] ?? ello, orld! Print[RemoveAmong[12930, 0'2'4'6'8]] ?? 12930
Try it online!

RemoveFirst[[(*)] list, (*) ent] → [(*)] (list)

Reforms result.

Returns list without the first occurrence of ent.

Example

Print[RemoveFirst[[1, 2, 3, 3, 4, 4, 5], 3]] ?? [1, 2, 3, 4, 4, 5] Print[RemoveFirst["Hello, World!", "l"]] ?? "Helo, World!" Print[RemoveFirst["Hello, World!", "ll"]] ?? "Hello, World!"
Try it online!

RemoveLast[[(*)] list, (*) ent] → [(*)] (list)

Reforms result.

Returns list without the first occurrence of ent.

Example

Print[RemoveLast[[1, 2, 3, 3, 4, 4, 3], 3]] ?? [1, 2, 3, 3, 4, 4] Print[RemoveLast["Hello, World!", "l"]] ?? "Hello, Word!" Print[RemoveLast["Hello, World!", "ll"]] ?? "Hello, World!"
Try it online!

Repeat[number ent, amt] → [(*)] (list)

Vectorizes.

Returns ent repeated amt times.

Example

Print[Repeat["Hello!", 3]] ?? ["Hello!", "Hello!", "Hello!"] Print[Repeat[4, 0]] ?? [] Print[Repeat[9, 1:5]] ?? [[9], [9, 9], [9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9, 9]]
Try it online!

Replace[string str, string|regex search, string replace?] → string (string)

Replaces all occurrences of search in str with replace.

Arguments

- : "".

ReplaceF[string str, string|regex search, fn func] → string (string)

For each e matching search found in str, replaces it with func[e].

Example

Print[ReplaceF["Student 9234-B hsa received a 97.03% on their test.", /"\\d+", Reverse]] ?? Student 4329-B hsa received a 79.30% on their test.
Try it online!

ReplaceMultiple[string str, ConfigureValue ...args] → string (string)

For each ConfigureValue search -> replace in args, replaces all occurrences of search in str with replace. Works iteratively, starting with the first replacement.

Example

Print[ReplaceMultiple[ "Hello, World!", ll -> "no", oo -> "", l -> "q" ]] ?? Hen, Worqd!
Try it online!

Resize[[(*)] list, number size] → [(*)] (list)

Reforms result.

Resizes list to be of length size, cyclically repeating elements if size exceeds #list.

Example

Print[Resize["Hello!", 2]] ?? He Print[Resize[[1, 2], 7]] ?? [1, 2, 1, 2, 1, 2, 1]
Try it online!

Retrieve[string name] → (*) (scope)

Returns the value of the variable whose name is name.

Example

a := 323 Print[Retrieve[$a]] ?? 323
Try it online!

Reverse[(*) ent] → (*) (list)

Reverses the elements of ent.

RLE[(*) list] → [[(*), number]] (list)

Returns an array representing the run-length encoded version of list.

Example

Display[RLE["hmmmmm..."]] "h" 1 "m" 5 "." 3
Try it online!

RNG[number seed=Random.new_seed] → RNG (numeric/random)

Returns an RNG, seeded with seed, or a random value if unspecified.

Root[number b, number n] → number (numeric)

Vectorizes.

Returns the bth root of n.

Rot[string str, number amount=13] → str (string)

Vectorizes.

Translates every alphabetic character in str amount character to the right, wrapping around.

Example

Print[Rot["Hello, World!"]] ?? Uryyb, Jbeyq! Print[Rot["Hello, World!", 1]] ?? Ifmmp, Xpsme! Print[Rot["Ifmmp, Xpsme!", -1]] ?? Hello, World!
Try it online!

Rotate[[(*)] list, number amount=1] → [(*)] (list)

Vectorizes.

Rotates list to the left by amount.

Example

Print[Rotate[1:5, 2]] ?? [3, 4, 5, 1, 2] Print[Rotate["Sorry!", -1]] ?? !Sorry
Try it online!

Rotations[[(*)] list] → [(*)] (list)

Returns all rotations of list.

Example

Display[Rotations[1:5]] 1 2 3 4 5 2 3 4 5 1 3 4 5 1 2 4 5 1 2 3 5 1 2 3 4
Try it online!

Round[number n, number r?] → number (numeric)

Vectorizes.

Returns n rounded half-up to the nearest integer.

Arguments

number r? - the precision to round. No precision if omitted.

Same[[(*)] ...args] → bool (list)

Returns true if every member in each argument is the same.

Example

Print[Same[1:5]] ?? false Print[Same[ [1, 1, 1, 1] ]] ?? true Print[Same[ [1:3, 1:3, 1:3] ]] ?? true
Try it online!

Save[(*) ...args] → [(*)] (meta)

Updates values of global abstracts, respective to args. _1 would become args[0], and _n would become args[n-1].

Series[fn[number] f, number max, number start?, **config] → [number] (functional)

Obtains all non-negative values under max by repeating f.

Options

include → determines whether or not to include max as an upperbound. Default: false

Example

Print[Series[Prime, 13]] ?? [2, 3, 5, 7, 11] Print[Series[Prime, 13, include->true]] ?? [2, 3, 5, 7, 11, 13]
Try it online!

SeriesIf[fn[n] f, fn[n->b] cond, number max, number start?, **config] → [number] (functional)

Obtains all non-negative values under max which satisfy cond by repeating f.

Options

include → determines whether or not to include max as an upperbound. Default: false

Example

Print[SeriesIf[Prime, Odd, 13]] ?? [3, 5, 7, 11] Print[SeriesIf[Prime, Odd, 13, include->true]] ?? [3, 5, 7, 11, 13]
Try it online!

Shift[[(*)] list, count=nil] → (*) (list)

Pops a member from the start of list, modifying it. Returns that element.

Shuffle[[(*)] list, **opts] → [(*)] (list/random)

Reforms result.

Shuffles the contents of list.

Options

RNG → specifies which RNG to shuffle by.

Sign[number n] → number (numeric)

Vectorizes.

Returns the sign of n; Returns -1 if n is negative, 1 if it is positive, and 0 otherwise.

Sin[number n] → number (numeric/trig)

Vectorizes.

Calculates sin(n).

Sinh[number n] → number (numeric/trig)

Vectorizes.

Calculates sinh(n).

Slices[[(*)] list, number|[number] skew=(1..list.size).to_a] → [[(*)]] (list)

Returns all slices of list of length skew.

Example

Print[Slices[1:6, 2]] ?? [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]
Try it online!

SlicesFill[[(*)] list, number|[number] skew=(1..list.size).to_a, **opts] → [[(*)]] (list)

Returns all slices of list of length skew, including an implied threshold of entities to the left and right of list.

Options

fill → The entity to fill the threshold. Default: 0.

compact → If true, removes the treshold after the slices are generated. Default: false.

repeat

Example

Print[SlicesFill[1:6, 2]] ?? [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]] Print[SlicesFill["a":"f", 2, fill->" "]] [[" ", "a"], ["a", "b"], ["b", "c"], ["c", "d"], ["d", "e"], ["e", "f"], ["f", " "]] Print[SlicesFill[1:3, 2, compact->true]] ?? [[1], [1, 2], [2, 3], [3]] Print[SlicesFill[1:3, 2, repeat->3]] ?? [[0, 0], [0, 0], [0, 1], [1, 2], [2, 3], [3, 0], [0, 0], [0, 0]]
Try it online!

Sparse[[(*)] list, (*) search?] → hash (list)

Converts list to a hash of sparse values.

Arguments

(*) search? - if specified, treats search as the assumed value.

Example

rand := Configure[Random, RNG->RNG[104]] vals := Do[ N@{ rand[] < 0.1 }, 100] Print[Sparse[vals]] ?? {11=>1, 32=>1, 35=>1, 43=>1, 51=>1, 55=>1, 67=>1, 71=>1, 86=>1}
Try it online!

Split[string str, string|regex sep?] → [string] (string)

Vectorizes.

Splits str on occurrences of sep. When sep is omitted, splits str on whitespace.

Sqrt[number n] → number (numeric)

Vectorizes.

Returns the square root of n. The result is imaginary if n is negative.

Square[number n] → number (numeric)

Vectorizes.

Returns the square of n.

StdDev[[number] list] → number (list)

Calculates the standard deviation of list.

Stdin[] → string (IO)

Reads all of STDIN.

Stdout[(*) ...args] → nil (IO)

Writes args, joined together, to STDOUT.

String[(*) ent, ...modes] → string (conversion)

Converts ent to a string.

Subtract[number ...args] → number (numeric)

Subtracts each number in args by the next. That is, folding subtraction over args.

Succ[(*) ent] → (*) (data)

Returns the successor of ent.

Suffixes[[(*)] list] → [[(*)]] (list)

Reforms result's elements.

Returns the non-empty suffixes of list.

Example

Print[Suffixes[1:5]] ?? [[1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5]] Print[Suffixes["hi?"]] ?? ["hi?", "i?", "?"] Print[Suffixes[901]] ?? [901, 1, 1]
Try it online!

TakeWhile[fn cond, [(*)] list] → list (functional)

Reforms result.

Returns elements from list until before the first element which does not satisfy cond.

Example

Display[TakeWhile[{_ /= sp}, "Hello, World!"]] ?? "Hello," Print[TakeWhile[Even, [2, 4, 6, 1, 2, 3]]] ?? [2, 4, 6] Print[TakeWhile[IsPrime, 357923]] ?? 357
Try it online!

Tan[number n] → number (numeric/trig)

Vectorizes.

Calculates tan(n).

Tanh[number n] → number (numeric/trig)

Vectorizes.

Calculates tan(n).

Tie[(*)|fn ...args] → (*)|fn (functional)

Ties args together.

Arguments

(*) args - Concatenates all args together.

fn args - Creates a tie between all of args.

Example

Print[Tie[1:3, 5:7]] ?? [1, 2, 3, 5, 6, 7] f := Tie[Double, Halve] Print[f[1, 2, 3, 4, 5, 6]] ?? [2, 1, 6, 2, 10, 3]
Try it online!

TieArray[fn ...funcs] → fn (functional)

Tie, but applied to the first argument instead of all arguments.

Example

f := TieArray[Double, Halve] Print[f[1:6]] ?? [2, 1, 6, 2, 10, 3]
Try it online!

ToBase[number num, number base] → [number] (numeric/bases)

Vectorizes.

Converts num to base base.

Translate[string str, string source, string repl] → string (string)

Replaces each character in source with the respective character in repl in str. Character ranges are specified with -.

Example

Print[Translate["Hello, World!", "a-z", "A-Z"]] ?? "HELLO, WORLD!" Print[Translate["No one is here today, James", "a-zA-Z", "A-Za-z"]] ?? "nO ONE IS HERE TODAY, jAMES"
Try it online!

TriangleRange[number a, number b] → [[number, number]] (list)

Returns an array of lists representing all pairs (x, y) such that a <= y <= b and a <= x < y.

TriangleSelect[fn cond, number a, number b] → [[number, number]] (list)

Returns an array of lists representing all pairs (x, y) satisfying cond such that a <= y <= b and a <= x < y.

Triangular[number n] → number (numeric/series)

Vectorizes.

Returns the nth Triangular number.

Example

Print[Triangular[0:5]] Print[Polygonal[0:5, 3]] ?? [0, 1, 3, 6, 10, 15]
Try it online!

Truthy[(*) arg] → bool (logic)

Returns true if arg is truthy, false otherwise.

typeof ((*) el) → Type (unary operator)

Returns the type of el.

UnBin[[number] n] → number (numeric/bases)

Converts from base 2 (binary) to base 10.

UnHex[[number] n] → number (numeric/bases)

Converts from base 16 (hexadecimal) to base 10.

Union[[(*)] ...lists] → [(*)] (list)

Returns an array representing the union of all lists in lists.

Unique[[(*)] list, number count?] → [(*)] (list)

Vectorizes. Reforms result.

Returns the non-duplicated elements in list.

Arguments

number count? - Limits the occurences of each element to count.

Example

Print[Unique[ [1, 2, 3, 2, 4, 7, 6, 7] ]] ?? [1, 2, 3, 4, 7, 6] keep2 := Unique&2 Print[keep2[ [1, 2, 2, 3, 3, 3, 4, 9, 9, 9, 9, 5] ]] ?? [1, 2, 2, 3, 3, 4, 9, 9, 5] Print[Unique["Hello, World!"]] ?? Helo, Wrd! Display => Unique["There are certain people here!", 0:8] ?? "" ?? "Ther actinpol!" ?? "There ar ctainpoplh!" ?? "There are crtain poplh!" ?? "There are certain popl hr!" ?? "There are certain peopl hr!" ?? "There are certain people hr!" ?? "There are certain people her!" ?? "There are certain people here!"
Try it online!

UniqueBy[fn map, [(*)] list, number count?] → [(*)] (list)

Curries. Reforms result.

Returns the non-duplicated elements in list according to the image of map.

Arguments

number count? - Limits the occurences of each element to count.

Example

words := ["Hello!", "world", "no!", "1234", "I swear I lived", "azure"] Print[UniqueBy[Last, words]] ?? ["Hello!", "world", "1234", "azure"] ClassNamed[Person]! { name .= _1 age .= _2 $string[] .= $"${name}, age ${age}" } people := [ Person["John", 14], Person["Riker", 15], Person["Jackson", 15], Person["Amy", 13], Person["Marie", 14], Person["Teressa", 16] ] by_age := UniqueBy[.age] Print => by_age[people] ?? John, age 14 ?? Riker, age 15 ?? Amy, age 13 ?? Teressa, age 16
Try it online!

UnOct[[number] n] → number (numeric/bases)

Converts from base 8 (octal) to base 10.

Unshift[[(*)] list, (*) ...args] → [(*)] (list)

Pushes args to the start of list, modifying it. Returns list.

UnSparse[Hash[(*) -> (*)] ent, (*) fill?] → [(*)] (list)

Treats ent as a hash where keys are indices and values are values, and converts to an array, filling in empty values with fill.

Arguments

(*) fill? - default: nil.

Example

test := <~ 0 -> 3, 2 -> 4, 6 -> 3 ~> Print[UnSparse[test]] ?? [3, 0, 4, 0, 0, 0, 3] Print[UnSparse[test, nil]] ?? [3, nil, 4, nil, nil, nil, 3]
Try it online!

Upcase[string str] → string (string)

Vectorizes.

Replaces all lowercase letters in str with the respective uppercase one.

Example

Print[Upcase["Hello, World!"]] ?? HELLO, WORLD! Print[Upcase[">>> NO ONE"]] ?? >>> NO ONE Print[Upcase["le monde"]] ?? LE MONDE
Try it online!

UpperTriangle[[[(*)]] mat, bool strict?] → [[(*)]] (list/matrix)

Returns the upper triangle of mat, where the remaining values are replaced with zeroes.

Arguments

bool strict? - If true, includes the diagonal. Default: true.

Example

mat := Integers[3, 3] + 1 Display[mat] ?? 1 2 3 ?? 4 5 6 ?? 7 8 9 Display[UpperTriangle[mat]] ?? 1 2 3 ?? 0 5 6 ?? 0 0 9 Display[UpperTriangle[mat, true]] ?? 0 2 3 ?? 0 0 6 ?? 0 0 0
Try it online!

V[(*) ...args] → [(*)] (data)

Returns an array of the arguments.

Wait[number n=NOT_PROVIDED] → number (IO)

Sleeps for `n` seconds, or indefinitely if no argument is provided. Returns `n`.

While[expression cond, expression body] → (*) (logic)

While cond evaluates as truthy, evaluates body. Returns nil if cond was false before executing body.

Example

i := 0 While[i < 5, Print[i]; i := i + 1] ?? 0 ?? 1 ?? 2 ?? 3 ?? 4 While[false, Print["Hello!"]] ?? nothing is printed
Try it online!

Xnor[(*) a, (*) b] → bool (logic)

Logical biconditional. Returns true if both a and b are truthy or falsey, false otherwise.

Example

Print[TruthTrablePretty["Xnor", 2]] ?? A | B | Xnor[A, B] ?? ---+---+------------ ?? 0 | 0 | 1 ?? 0 | 1 | 0 ?? 1 | 0 | 0 ?? 1 | 1 | 1
Try it online!

Xor[(*) a, (*) b] → bool (logic)

Logical exclusive disjunction. Returns true if exactly one of a and b are truthy, false otherwise.

Example

Print[TruthTrablePretty["Xor", 2]] ?? A | B | Xor[A, B] ?? ---+---+----------- ?? 0 | 0 | 0 ?? 0 | 1 | 1 ?? 1 | 0 | 1 ?? 1 | 1 | 0
Try it online!

((*) a) xor ((*) b) → bool (operator/logic)

Returns true if exactly one of a and b is truthy, false otherwise.

Zero[number n] → bool (numeric/logic)

Vectorizes.

Returns true if n is 0, otherwise false.