Collections

ACCESS

(list:access [INT] [LIST])
(set:access [INT] [SET])

Returns the value of the [INT]th element in the collection.

ACCESS CONSTANT INDEX

[(LIST) VAR].{Integer}
[(SET) VAR].{Integer}

Returns a variable corresponding to the [INT]th element in the collection.

ADD ELEMENT AT

(list:add_element_at [INT] [COMPUTATION*] [LIST])

Returns a copy of [LIST] with [COMPUTATION*] added at index [INT]. Note that [COMPUTATION*] does not allow use of the variable shorthand if [LIST] is a list of strings.

ADD ELEMENT

(list:add_element [C0 = COMPUTATION*] ... [CN = COMPUTATION*] [LIST])
(set:add_element [C0 = COMPUTATION*] ... [CN = COMPUTATION*] [SET])

Returns a copy of [COLLECTION] with C0CN added. If [COLLECTION] is a [LIST], then the elements are added at the end of the list, in order (meaning that CN will be the last element added). Note that [COMPUTATION*] does not allow use of the variable shorthand if the collection is a collection of strings.

ADDING MEMBERS

(list:add_all_elements [C0 = LIST|SET]+ [C1 = LIST])
(set:add_all_elements [C0 = LIST|SET]+ [C1 = SET])

Returns a copy of [C1], with all the elements of [C0] added. If [C1] is a [LIST], the new members are added at the end of the list.

As a shorthand, multiple [C0] can be specified. They will all be added in order.

SUB-LIST

(list:sublist [start: INT] [end_before: INT] [LIST])
(set:subset [start: INT] [end_before: INT] [SET])

Returns a copy of the collection in which only the elements with an index higher or equal to [start] and strictly less than [end_before] are included.

SHUFFLE

(list:shuffle [LIST])
(set:shuffle [SET])

Returns a list containing all the elements of the collection in a random order.

COUNT

(list:count [COMPUTATION*] [LIST])
(set:count [COMPUTATION*] [SET])

Returns the number of occurrences of [COMPUTATION*] in [LIST] or [SET]. Note that [COMPUTATION*] does not allow use of the variable shorthand if the collection is a collection of strings.

INDEX OF

(list:index_of [COMPUTATION] [LIST])
(set:index_of [COMPUTATION] [SET])

Returns the index of the first occurrence of [COMPUTATION] in [LIST] or [SET], starting at 0.

IS MEMBER

(list:is_member [COMPUTATION] [LIST])
(set:is_member [COMPUTATION] [SET])

Returns true if, and only if, [COMPUTATION] is in [LIST] or [SET].

SIZE

(list:size [LIST])
(set:size [SET])

Returns the size ([INT]) of [LIST] or [SET].

IS EMPTY

(list:is_empty [LIST])
(set:is_empty [SET])

Returns true if, and only if [LIST] or [SET] is empty.

REMOVE ONE COPY

(list:remove [COMPUTATION*]+ [LIST])
(set:remove [COMPUTATION*]+ [SET])

Returns a copy of the collection with one instance of [COMPUTATION*] having been removed. The variable shorthand cannot be used if the collection is a collection of strings.

As a shorthand, multiple computations can be specified. They will all be removed in order.

REMOVE ALL COPIES

(list:remove_each [COMPUTATION*]+ [LIST])
(set:remove_each [COMPUTATION*]+ [SET])

Returns a copy of the collection with all instances of [COMPUTATION*] having been removed. The variable shorthand cannot be used if the collection is a collection of strings.

As a shorthand, multiple computations can be specified. They will all be removed from the list.

REMOVE ALL ALSO IN

(list:remove_all [removed: COLLECTION]+ [LIST])
(set:remove_all [removed: COLLECTION]+ [SET])

Returns a copy of the collection with all elements of [removed] having been removed.

As a shorthand, multiple [removed] can be specified. Their elements will all be removed.

REMOVE AT

(list:remove_at [INT] [LIST])
(set:remove_at [INT] [SET])

Returns a copy of the collection with the element at index [INT] having been removed.

PUSH ELEMENT

(list:push_left [COMPUTATION*] [LIST])
(list:push_right [COMPUTATION*] [LIST])
(set:push_left [COMPUTATION*] [SET])
(set:push_right [COMPUTATION*] [SET])

Returns a list corresponding to the given [LIST] or [SET] to which the [COMPUTATION*] has been added to the right (push_right) or the left (push_left).

POP ELEMENT

TODO

PARTITION

TODO

PARTITION (INDEXED)

TODO

SORT

TODO

FILTER ELEMENTS

(list:filter [LAMBDA BOOL (X)] [X LIST])
(set:filter [LAMBDA BOOL (X)] [X SET])

Returns a copy of [X LIST] or [X SET] in which only the elements for which [LAMBDA BOOL (X)] returns true remain.

FILTER ELEMENTS (INDEXED)

(list:indexed_filter [LAMBDA BOOL (INT X)] [X LIST])
(set:indexed_filter [LAMBDA BOOL (INT X)] [X SET])

Returns a copy of [X LIST] or [X SET] in which only the elements for which [LAMBDA BOOL (INT X)] (with INT being the element’s index) returns true remain.

FOLD OVER COLLECTION

(list:foldl [LAMBDA X (X Y)] [X COMPUTATION*] [Y LIST])
(list:foldr [LAMBDA X (X Y)] [X COMPUTATION*] [Y LIST])
(set:foldl [LAMBDA X (X Y)] [X COMPUTATION*] [Y SET])
(set:foldr [LAMBDA X (X Y)] [X COMPUTATION*] [Y SET])

Returns the result of iterating [LAMBDA X (X Y)] over [Y COLLECTION], with [X COMPUTATION*] being the initial value. The direction of the iteration is by ascending index order when using foldl, and the opposite order when using foldr. The variable shorthand cannot be used for the initial value if the lambda function returns a string.

MERGE COLLECTIONS

(list:merge [LAMBDA O (X Y)] [X LIST|X SET] [Y LIST|Y SET])
(set:merge [LAMBDA O (X Y)] [X LIST|X SET] [Y LIST|Y SET])
Merges two collections into either a list (list:merge) or a set (set:merge). This version of merging only continues as long as both collections have elements. Thus, extra elements in either list are ignored.

SAFE-MERGE COLLECTIONS

(list:safe_merge [LAMBDA O (X Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION])
(set:safe_merge [LAMBDA O (X Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION])
Safely merges two collections into either a list (list:safe_merge) or a set (set:safe_merge). This version of merging continues as long as either collection has elements. If one of the two collections runs out of elements before the other, it uses the provided default value ([X COMPUTATION] for the first list, [Y COMPUTATION] for the second one).

MERGE COLLECTIONS (INDEXED)

(list:indexed_merge [LAMBDA O (INT X Y)] [X LIST|X SET] [Y LIST|Y SET])
(set:indexed_merge [LAMBDA O (INT X Y)] [X LIST|X SET] [Y LIST|Y SET])
Merges two collections into either a list (list:merge) or a set (set:merge). This version of merging only continues as long as both collections have elements. Thus, extra elements in either list are ignored. The first parameter passed to the lambda function is the index of the element in both collections.

SAFE-MERGE COLLECTIONS (INDEXED)

(list:indexed_safe_merge [LAMBDA O (INT X INT Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION])
(set:indexed_safe_merge [LAMBDA O (INT X INT Y)] [X LIST|X SET] [X COMPUTATION] [Y LIST|Y SET] [Y COMPUTATION])
Safely merges two collections into either a list (list:safe_merge) or a set (set:safe_merge). This version of merging continues as long as either collection has elements. If one of the two collections runs out of elements before the other, it uses the provided default value ([X COMPUTATION] for the first list, [Y COMPUTATION] for the second one). The first and third parameters passed to the lambda function correspond to the index of the element in either collection. It does not increase if the collection has no more elements and is using the default value.