Concatenates two arrays.
Type Value
Input Arr<<A Any>...>an array
other (param #1) Arr<<B Any>...>another array
Output Arr<<A Any>|<B Any>...>the concatenation of both arrays
Program Type Value Error
[1, 2, 3] +[4, 5]Arr<Num...>[1, 2, 3, 4, 5]
[] +[4, 5]Arr<Num...>[4, 5]
[1, 2, 3] +[]Arr<Num...>[1, 2, 3]
[] +[]Arr<>[]
["a", "b"] +["c", "d"]Arr<Str...>["a", "b", "c", "d"]
["a", "b"] +[1, 2]Arr<Str|Num...>["a", "b", 1, 2]
Checks if all elements are true.
Type Value
Input Arr<Bool...>an array of boolean values
Output Booltrue iff all elements of the input are true
Program Type Value Error
[] allBooltrue
[true] allBooltrue
[true, true] allBooltrue
[true, false, true] allBoolfalse
Removes the first n elements from the beginning of an array.
Type Value
Input Arr<<A Any>...>an array
n (param #1) Numnumber of elements to remove
Output Arr<<A Any>...>the input with the first n elements removed
Program Type Value Error
[1, 2, 3] drop(-1)Arr<Num...>[1, 2, 3]
[1, 2, 3] drop(0)Arr<Num...>[1, 2, 3]
[1, 2, 3] drop(1)Arr<Num...>[2, 3]
[1, 2, 3] drop(2)Arr<Num...>[3]
[1, 2, 3] drop(3)Arr<Num...>[]
[1, 2, 3] drop(4)Arr<Num...>[]
Removes elements satisfying a predicate from the beginning of an array.
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to the elements of the input
Output Arr<<A Any>...>The elements from the input, starting with the first one that does not satisfy the predicate.
Program Type Value Error
[{a: 1}, {a: 2}, {b: 3}, {a: 4}] dropWhile(is {a: _})Arr<Obj<b: Num, Void>|Obj<a: Num, Void>...>[{b: 3}, {a: 4}]
Applies a function to every element.
Type Value
Input Arr<<A Any>...>an array
f (param #1) for <A Any> <B Any>a function to apply to each element of the input
Output Arr<<B Any>...>a list with the outputs of f applied to each element of the input
Program Type Value Error
[1, 2, 3] each(*2)Arr<Num...>[2, 4, 6]
[{a: 1}, {a: 2}, {b: 3}, {a: 4}] takeWhile(is {a: _}) each(@a)Arr<Num...>[1, 2]
Pairs each element with a 0-based index.
Type Value
Input Arr<<A Any>...>
Output Arr<Arr<Num, <A Any>>...>the input with each element replaced with a 2-element array, the second element of which is the original element and the first is its index in the array, counting from 0
Program Type Value Error
["a", "b", "c"] enumArr<Arr<Num, Str>...>[[0, "a"], [1, "b"], [2, "c"]]
Pairs each element with an index.
Type Value
Input Arr<<A Any>...>an array
start (param #1) Numat which number to start counting
Output Arr<Arr<Num, <A Any>>...>the input with each element replaced with a 2-element array, the second element of which is the original element and the first is its index in the array, counting from start
Program Type Value Error
["a", "b", "c"] enum(1)Arr<Arr<Num, Str>...>[[1, "a"], [2, "b"], [3, "c"]]
Finds the index and first element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|Arr<Num, <A Any>>the first element of the input satisfying the predicate, paired with its index, or Null if none
Program Type Value Error
[1, 2, 3] findFirst(is Num with %2 ==0)Null|Arr<Num, Num>[1, 2]
[1, 2, 3] findFirst(is Num with %4 ==0)Null|Arr<Num, Num>null
Finds the index of the first element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|Numthe index of the first element of the input satisfying the predicate, or Null if none
Program Type Value Error
[1, 2, 3] findFirstIndex(is Num with %2 ==0)Null|Num1
[1, 2, 3] findFirstIndex(is Num with %4 ==0)Null|Numnull
Finds the first element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|<A Any>the first element of the input satisfying the predicate, or Null if none
Program Type Value Error
[1, 2, 3] findFirstValue(is Num with %2 ==0)Null|Num2
[1, 2, 3] findFirstValue(is Num with %4 ==0)Null|Numnull
Finds the index and last element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|Arr<Num, <A Any>>the last element of the input satisfying the predicate, paired with its index, or Null if none
Program Type Value Error
[1, 2, 3, 4] findLast(is Num with %2 ==0)Null|Arr<Num, Num>[3, 4]
[1, 2, 3, 4] findLast(is Num with %8 ==0)Null|Arr<Num, Num>null
Finds the index of the last element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|Numthe index of the last element of the input satisfying the predicate, or Null if none
Program Type Value Error
[1, 2, 3, 4] findLastIndex(is Num with %2 ==0)Null|Num3
[1, 2, 3, 4] findLastIndex(is Num with %8 ==0)Null|Numnull
Finds the last element satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Null|<A Any>the last element of the input satisfying the predicate, or Null if none
Program Type Value Error
[1, 2, 3, 4] findLastValue(is Num with %2 ==0)Null|Num4
[1, 2, 3, 4] findLastValue(is Num with %8 ==0)Null|Numnull
Aggregates an array recursively.
Type Value
Input Arr<<A Any>...>an array
start (param #1) <B Any>initial accumulator
combine (param #2) for <B Any> (<A Any>) <B Any>a function that combines the current accumulator with the next element to produce a new accumulator
Output <B Any>the accumulator after processing all elements
Program Type Value Error
[2, 3, 4] fold(0, +)Num9
[2, 3, 4] fold(1, *)Num24
Returns the element at a given index.
Type Value
Input Arr<<A Any>...>an array
index (param #1) Numa 0-based index into the input
Output <A Any>the element at the given index
Throws BadIndex if the index is invalid or NoSuchIndex if there is not element at the give index.
Program Type Value Error
[] get(0)VoidType error Code: VoidProgram Message: Type of program cannot be Void.
["a", "b", "c"] get(0)Str"a"
["a", "b", "c"] get(-1)StrValue error Code: BadIndex Message: Index must be a nonnegative integer. Got value: -1
["a", "b", "c"] get(2)Str"c"
["a", "b", "c"] get(3)StrValue error Code: NoSuchIndex Message: Array is not long enough. Got value: 3
Returns the element at a given index, or a default value.
Type Value
Input Arr<<A Any>...>an array
index (param #1) Numa 0-based index into the input
default (param #2) <B Any>default value to retur if there is no element at the given index
Output <A Any>|<B Any>the element at the given index, or default if there isn't one.
Throws BadIndex if the index is invalid.
Program Type Value Error
[] get(0, null)Nullnull
["a", "b", "c"] get(0, null)Str|Null"a"
["a", "b", "c"] get(-1, null)Str|NullValue error Code: BadIndex Message: Index must be a nonnegative integer. Got value: -1
["a", "b", "c"] get(3, null)Str|Nullnull
Join several arrays together into one.
Type Value
Input Arr<Arr<<A Any>...>...>an array of arrays
Output Arr<<A Any>...>All arrays in the input joined together into one.
Program Type Value Error
[] joinArr<<A>...>[]
[[]] joinArr<>[]
[[1]] joinArr<Num...>[1]
[[1, 2]] joinArr<Num...>[1, 2]
[[], []] joinArr<>[]
[[], [1]] joinArr<Num...>[1]
[[1], [2, 3]] joinArr<Num...>[1, 2, 3]
[[1], [2, [3]]] joinArr<Num|Arr<Num>...>[1, 2, [3]]
Keep only elements satisfying a predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Arr<<B Any>...>The input with all elements not satisfying the predicate removed.
Program Type Value Error
["a", 1, "b", 2, "c", 3] keep(is Num with %2 >0 elis Str)Arr<Num|Str...>["a", 1, "b", "c", 3]
[{n: 1}, {n: 2}, {n: 3}] keep(is {n: n} with n %2 >0)Arr<Obj<n: Num, Void>...>[{n: 1}, {n: 3}]
[1, 2, 3, 4, 5, 6] keep(if %2 ==0) each(*2)Arr<Num...>[4, 8, 12]
[1, 2, 3, 4, 5, 6] keep(if %2 ==0 not) each(id)Arr<Num...>[1, 3, 5]
[1, 2, 3] keep(if %2 ==0 not) each(+1)Arr<Num...>[2, 4]
[1, 2, 3] keep(if false)Arr<Num...>[]
[{n: 1}, 2, {n: 3}] keep(is {n: n}) each(@n)Arr<Num...>[1, 3]
Computes the length of an array.
Type Value
Input Arr<Any...>an array
Output Numhow many elements the input has
Program Type Value Error
[] lenNum0
["a", 2, []] lenNum3
Finds the maximum element.
Type Value
Input Arr<<A Any>...>an array
less (param #1) for <A Any> (<A Any>) Boolfuncer that tests whether its input is "less than" its first argument
default (param #2) <B Any>default value to return if the input is empty
Output <A Any>|<B Any>the maximum element, or default if the input is empty
Program Type Value Error
["abc", "b", "ab"] max(<, "")Str"b"
[0, 1, 2] max(>, -100)Num0
for Any def f Arr<Num...> as [] ok f max(<, 0)Num0
Finds the maximum element according to a sorting key.
Type Value
Input Arr<<A Any>...>an array
sortKey (param #1) for <A Any> <B Any>funcer that maps input elements to values by which they will be compared
less (param #2) for <B Any> (<B Any>) Boolfuncer that tests whether its input is "less than" its first argument
default (param #3) <C Any>default value to return if the input is empty
Output <A Any>|<C Any>the maximum element, or default if the input is empty
Program Type Value Error
["abc", "b", "ab"] max(bytes len, <, "")Str"abc"
Finds the minimum element.
Type Value
Input Arr<<A Any>...>an array
less (param #1) for <A Any> (<A Any>) Boolfuncer that tests whether its input is "less than" its first argument
default (param #2) <B Any>default value to return if the input is empty
Output <A Any>|<B Any>the minimum element, or default if the input is empty
Program Type Value Error
["abc", "b", "ab"] min(<, "")Str"ab"
Finds the minimum element according to a sorting key.
Type Value
Input Arr<<A Any>...>an array
sortKey (param #1) for <A Any> <B Any>funcer that maps input elements to values by which they will be compared
less (param #2) for <B Any> (<B Any>) Boolfuncer that tests whether its input is "less than" its first argument
default (param #3) <C Any>default value to return if the input is empty
Output <A Any>|<C Any>the minimum element, or default if the input is empty
Program Type Value Error
["abc", "b", "ab"] min(bytes len, <, "")Str"b"
Builds a range of numbers
Type Value
Input Anyany value (is ignored)
from (param #1) Numlower limit (inclusive)
to (param #2) Numupper limit (inclusive)
Output Arr<Num...>an array with the integers in the specified interval
Program Type Value Error
range(0, 4)Arr<Num...>[0, 1, 2, 3]
range(-1, 2)Arr<Num...>[-1, 0, 1]
range(3, 2)Arr<Num...>[]
Concatenates an array with copies of itself.
Type Value
Input Arr<<A Any>...>an array
times (param #1) Numhow many times to repeat the input
Output Arr<<A Any>...>the elements of the input repeated times times in a single array
Program Type Value Error
[1, 2, 3] repeat(3)Arr<Num...>[1, 2, 3, 1, 2, 3, 1, 2, 3]
[1, 2, 3] repeat(0)Arr<Num...>[]
[1, 2, 3] repeat(1)Arr<Num...>[1, 2, 3]
Reverses an array.
Type Value
Input Arr<<A Any>...>an array
Output Arr<<A Any>...>the input in reverse order
Program Type Value Error
[1, 2, 3] revArr<Num...>[3, 2, 1]
[] revArr<>[]
Checks if some element is true.
Type Value
Input Arr<Bool...>an array of boolean values
Output Booltrue iff at least one element of the input is true
Program Type Value Error
[] someBoolfalse
[false] someBoolfalse
[false, false] someBoolfalse
[false, true, false] someBooltrue
Sorts numbers.
Type Value
Input Arr<Num...>an array of numbers
Output Arr<Num...>the input sorted from smallest to greatest
Program Type Value Error
[7, 3, 2, 5, 2] sortArr<Num...>[2, 2, 3, 5, 7]
Sorts strings.
Type Value
Input Arr<Str...>an array of strings
Output Arr<Str...>the input sorted lexicographically
Program Type Value Error
"Zwölf Boxkämpfer jagen Victor quer über den großen Sylter Deich . Voilà !" fields sortArr<Str...>["!", ".", "Boxkämpfer", "Deich", "Sylter", "Victor", "Voilà", "Zwölf", "den", "großen", "jagen", "quer", "über"]
Sorts values.
Type Value
Input Arr<<A Any>...>an array
less (param #1) for <A Any> (<A Any>) Boolfuncer that tests whether its input is "less than" its first argument
Output Arr<<A Any>...>the input sorted by the given ordering function
Program Type Value Error
[7, 3, 2, 5] sort(>)Arr<Num...>[7, 5, 3, 2]
"Zwölf Boxkämpfer jagen Victor quer über den großen Sylter Deich . Voilà !" fields sort(>)Arr<Str...>["über", "quer", "jagen", "großen", "den", "Zwölf", "Voilà", "Victor", "Sylter", "Deich", "Boxkämpfer", ".", "!"]
[{a: 7}, {a: 3}, {a: 2}, {a: 5}] for Obj<a: Num, Void> def <(other Obj<a: Num, Void>) Bool as @a <(other @a) ok sort(<)Arr<Obj<a: Num, Void>...>[{a: 2}, {a: 3}, {a: 5}, {a: 7}]
[{a: 7, b: 2}, {a: 3, b: 1}, {a: 2, b: 2}, {a: 5, b: 2}] for Obj<a: Num, b: Num, Void> def <(other Obj<a: Num, b: Num, Void>) Bool as @b <(other @b) ok sort(<)Arr<Obj<a: Num, b: Num, Void>...>[{a: 3, b: 1}, {a: 7, b: 2}, {a: 2, b: 2}, {a: 5, b: 2}]
Sorts an array with a sorting key.
Type Value
Input Arr<<A Any>...>an array
sortKey (param #1) for <A Any> <B Any>funcer that maps input elements to values by which they will be compared
less (param #2) for <B Any> (<B Any>) Boolfuncer that tests whether its input is "less than" its first argument
Output Arr<<A Any>...>the input sorting according to the given sorting key and ordering function
Program Type Value Error
[{a: 7}, {a: 3}, {a: 2}, {a: 5}] sortBy(@a, <)Arr<Obj<a: Num, Void>...>[{a: 2}, {a: 3}, {a: 5}, {a: 7}]
[{a: 7, b: 2}, {a: 3, b: 1}, {a: 2, b: 2}, {a: 5, b: 2}] sortBy(@b, <)Arr<Obj<a: Num, b: Num, Void>...>[{a: 3, b: 1}, {a: 7, b: 2}, {a: 2, b: 2}, {a: 5, b: 2}]
Takes the first n elements from an array.
Type Value
Input Arr<<A Any>...>an array
n (param #1) Numnumber of elements to take
Output Arr<<A Any>...>array with the first n elements from the input
Program Type Value Error
[1, 2, 3] take(2)Arr<Num...>[1, 2]
[1, 2, 3] take(1)Arr<Num...>[1]
[1, 2, 3] take(0)Arr<Num...>[]
[1, 2, 3] take(-1)Arr<Num...>[]
[1, 2, 3] take(4)Arr<Num...>[1, 2, 3]
[1, 2, 3] take(3)Arr<Num...>[1, 2, 3]
Takes elements from the beginning of an array that satisfy a certain predicate .
Type Value
Input Arr<<A Any>...>an array
predicate (param #1) for <A Any> Obj<yes: <B Any>, Any>|Obj<no: <C Any>, Any>a predicate to apply to elements of the input
Output Arr<<B Any>...>an array with the elements that satisfy the predicate, up to and excluding the first one that doesn't
Program Type Value Error
[1, 3, 5, 2, 4, 7] takeWhile(if %2 ==1)Arr<Num...>[1, 3, 5]
[1, 3, 5, 2, 4, 7] takeWhile(if %2 ==0)Arr<Num...>[]
[{a: 1}, {a: 2}, {b: 3}, {a: 4}] takeWhile(is {a: _}) each(@a)Arr<Num...>[1, 2]