append
Returns a list with the specified values appended onto the end of list.
Used in the following format, where list
must be of type list, and there are no restrictions for value
or value*
:
append(list, value, [value*])
list.append(value, [value*])
The return value type is a list.
Examples
append(list(1, 2, 3), 4) # value: {1,2,3,4}
list(1, 2, 3).append(4) # value: {1,2,3,4}
append(list(1, 2, 3), 4, 5) # value: {1,2,3,4,5}
list(1, 2, 3).append(4, 5) # value: {1,2,3,4,5}
append(list(1, 2, 3), null, 5) # value: {1,2,3,null,5}
list(1, 2, 3).append(null, 5) # value: {1,2,3,null,5}
append(list(1, 2, 3), list(4, 5)) # value: {1,2,3,{4,5}}
list(1, 2, 3).append(list(4,5)) # value: {1,2,3,{4.5}}
apply
Evaluates the operator
with the specified parameters. Evaluates to null if the operator
parameter is null. If the parameter list
is null, uses an empty parameter list.
Used in the following format, where &operator
must be an operator with a prepended & and parameter-list
must be a list:
apply(&operator, parameter-list)
The return value type varies.
Examples
apply(&+, list(1, 2, 3, 4)) # value: 10
apply(&date, list()) # value: current date
filter
Constructs a list containing only those elements of the source list
for which the predicate operator
evaluates to true. The predicate operator
must take a single parameter. The predicate operator
is called on each element in the source list, and the value must be boolean (or null). If true, the element is included in the result list. If the predicate operator
does not evaluate to true for any of the elements in the source list, the result is an empty list.
Used in the following format, where predicate-operator
must be an operator, and &
must be prepended to the operator and source-list
must be a list:
filter(predicate-operator,source-list)
The return value type is a list.
Examples
filter(&isNotNull, list(null, 1, null, 2, 3, null, 4)) # value: { 1 2 3 4 }
find
Searches the list or dict
linearly starting at offset
for the value
value and returns the value's index in the array if found, -1 otherwise. If offset
is not specified, the search starts at the beginning of the array
.
Used in the following format, where array
must be a list or dict, value
is what is searched for and offset
must be an integer identifying the starting offset (only valid for lists):
find(array, value, [offset])
The return value type is an integer.
Examples
find(list(1, 2, 3, 4, 5), 2) # value: 1
list(1, 2, 3, 4, 5).find(2) # value: 1
find(list(1, 2, 3, 4, 5), 6) # value: -1
list(1, 2, 3, 4, 5).find(6) # value: -1
find(list(1, 2, 1, 2, 1), 2, 2) # value: 3
list(1, 2, 1, 2, 1).find(2, 2) # value: 3
flatten
Returns a list containing the concatenation of each of the entries from each of the input lists. Does not recursively flatten nested lists.
Used in the following format, where list1
, list2
and listX
must be lists:
flatten(list 1, {list l2}+)
The return value type is a list.
Examples
flatten(list(1,2), list(3, 4)) # value: {1,2,3,4}
flatten(list(1,2), list(3, 4), list(5, 6)) # value: {1,2,3,4,5,6}
getItem
Retrieves the list element at the specified index
(zero-indexed). Errors if the index
is out of range. Evaluates to null if either parameter is null.
Used in the following format, where list
must be a list and index
must be an integer or long integer:
getItem(list, index)
list.getItem(index)
The return value type varies.
Examples
getItem(list(1, "a", time(9, 30, 0)) 1) # value: "a"
list(1, "a", time(9, 30, 0)).getItem(1) # value: "a"
getItem(list(list(), list(1, "a", 75.0)) 0) # value: {}
list(list(), list(1, "a", 75.0)).getItem(0) # value: {}
len
Evaluates to the length of the given list
. Each element of the list always contributes 1 to the length count.
This means that if the list contains sub-elements that themselves
are lists, the len operator is not executed recursively.
Evaluates to null if the parameter is null.
Used in the following format, where list
must be a list:
len(list)
list.len()
The return value type is an integer.
Examples
len(list(1,"a",time(9,30,0))) # value: 3
list(1,"a",time(9,30,0)).len() # value: 3
len(list()) # value: 0
list().len() # value: 0
len(list(list(), list(1,"a","75.0"))) # value: 2
list(list(), list(1,"a","75.0"))).len() # value: 2
#Null elements also contribute 1 to the length count.
len(list(null, list(1, 2), 2) # value 3
list(null, list(1, 2), 2).len() # Value 3
list
Creates a list. The elements of the list may be any type.
Used in the following format, where expr
may be any expression:
list({expr}*)
{expr}*.list()
The return value type is a list.
Examples
list(1, "a", time(9,30,0)) # value: { 1 "a" 9:30:00 }
(1, "a", time(9,30,0)).list() # value: { 1 "a" 9:30:00 }
list() # value: {}
list(list(), list(1,"a",75.0)) # value: ( {} { 1 "a" 75.0 } }
(list(), list(1,"a",75.0)).list() # value: ( {} { 1 "a" 75.0 } }
map
Constructs a list containing the results of applying the operator to the elements of the source lists.
All source lists
must have the same length; the result list will have this length as well. The operator
must be preceded by an "&" and take n parameters, where n is the number of source lists passed. The operator
is called on each elements in the source lists, and the results are assembled into a list of the same length as the source lists.
Used in the following format, where operator
must be an operator or function, preceded by the "&" symbol, to show we don't want to evaluate the function, but rather pass it as an actual function name and source-lists
must all be lists of the same length:
map(operator, {source-list}+)
operator.map({source-list}+)
The return value type is a list.
Examples
map(&isNull, list(null, 1, null, 2, 3)) # value: { t f t f f }
map(&toUpper, list("a", "b" , "c")) # value: { A B C }
map(&+, list(100, 200), list(10, 20), list(1, 2)) # value: { 111 222 }
reduce
Evaluates to the result of chain-calling the operator
on each element in the source list
. The operator
must take two parameters. The operator
is called on the first two elements in the list, then on that result and the third element, then on that result and the fourth element, and so on. The final value is the result. If an initial value is provided, it is considered to precede all elements in the list. If only a single element is provided (1-length list and no initializer
or 0-length list and initializer
) then that element is the result value. Evaluates to null if the operator
or source list
is null. Null is a valid value for the initializer
.
Used in the following format, where &operator
must be an operator with a prepended &, source-list
must be a list and initializer
may be any expression:
reduce(&operator, source-list, [initializer])
The return value type varies.
Examples
reduce(&+, list(10,27,5.7) ) # value: 42.7
reduce(&+, list(10,27,5.7),11 ) # value: 53.7
setItem
Returns a copy of list
, with the value at index
index set to value
.
Used in the following format, where list
must be a list, index
must be an integer which is the position at which the value is modified and value
is what it is set to:
setItem(list, index, value)
list.setItem(index, value)
The return value type is an integer.
Examples
setItem(list(1, 2, 3, 4), 2, 5) # value: (1,2,5,4)
list(1, 2, 3, 4).setItem(2, 5) # value: (1,2,5,4)
slice
Returns the slice of length
length of the list
list starting at offset. If length
is omitted or negative, the rest of the list
starting at offset
is returned.
Used in the following format, where list
must be a list, offset
must be an integer identifying the starting offset and length
must be an integer identifying the size of the slice to return; default to remainder of list
:
slice(list, offset, [length])
list.slice(offset, [length])
The return value type is a list.
Examples
slice(list(1, 2, 3, 4, 5), 2, 2) # value: (3,4)
list(1, 2, 3, 4, 5).slice(2, 2) # value: (3,4)
slice(list(1, 2, 3, 4, 5), 2) # value: (3,4,5)
list(1, 2, 3, 4, 5).slice(2) # value: (3,4,5)
slice(list(1, 2, 3, 4, 5), 2, -1) # value: (3,4,5)
list(1, 2, 3, 4, 5).slice(2, -1) # value: (3,4,5)
splice
Remove the slice of length
length of the list
list starting at offset
. If length
is omitted or negative, the rest of the list starting at offset
is removed. Optionally, a replacement
list can be inserted in the place of the removed slice.
Used in the following format, where list
must be a list, offset
must be an integer identifying the starting offset, length
must be an integer identifying the size of the slice to return; default to remainder of list
, and replacement is a string that is inserted in place of the removed slice (does not need to be the same length as the removed slice):
splice(list, offset, [length], [replacement])
list.splice(offset, [length], [replacement])
The return value type is a list.
Examples
splice(list(1, 2, 3, 4, 5), 2) # value: {1,2}
list(1, 2, 3, 4, 5).splice(2) # value: {1,2}
splice(list(1, 2, 3, 4, 5), 2, -1) # value: {1,2}
list(1, 2, 3, 4, 5).splice(2, -1) # value: {1,2}
splice(list(1, 2, 3, 4, 5), 2, 2, list(6, 7)) # value: {1,2,6,7,5}
list(1, 2, 3, 4, 5).splice(2, 2, list(6, 7)) # value: {1,2,6,7,5}
splice(list(1, 2, 3, 4, 5), 2, 0, list(6, 7)) # value: {1,2,6,7,3,4,5}
list(1, 2, 3, 4, 5).splice(2, 0, list(6, 7)) # value: {1,2,6,7,3,4,5}