Purpose: Handling lists.
Given a whitespace-seperated enumeration of elements, builds a List of them in order.
Example:
[1 2 3 4 100]
Alternative "name": []
Represents the empty list.
Example:
nil
Result is whether l is the empty list (and any list at all).
Example:
if (nil? nil) 'yes else 'no => yes
Result is a list with head h and tail t.
Example:
if (list? (5:6:7:8:nil)) 'yes else 'no => yes head (5:6:7:8:nil) => 5 tail (5:6:7:8:nil) => (6:7:8:nil)
Result is whether l is something constructed by (:) .
Example:
if (cons? (5:6:7:8:nil)) 'yes else 'no => yes if (cons? nil) 'yes 'no => no if (cons? 42) 'yes 'no => no
Result is whether l is a list, i.e. something constructed by (:) or nil .
Example:
if (list? (5:6:7:8:nil)) 'yes else 'no => yes if (list? nil) 'yes else 'no => yes if (list? 42) 'yes else 'no => no
Result is the head of l.
Example:
head (5:6:7:8:nil) => 5 tail (5:6:7:8:nil) => (6:7:8:nil)
Result is the tail of l.
Example:
head (5:6:7:8:nil) => 5 tail (5:6:7:8:nil) => (6:7:8:nil) tail (8:nil) => nil
Result is a list with the first count elements of l.
Example:
take 2 (5:6:7:8:nil) => (5:6:nil) take (-2) (5:6:7:8:nil) => nil
Result is a list with all elements of l except for the first count elements.
Example:
drop 2 (5:6:7:8:nil) => (7:8:nil) drop (-2) (5:6:7:8:nil) => (5:6:7:8:nil)
Result is the length of the list l. This is quite slow (O(n)).
Example:
drop 2 (5:6:7:8:nil) => (7:8:nil) drop (-2) (5:6:7:8:nil) => (5:6:7:8:nil)
Result is a list of numbers.
The list starts with beginning (inclusive), listing all the numbers until frontier, spaced step apart.
Example:
range 0 10 1 => [0 1 2 3 4 5 6 7 8 9] range 5 10 1 => [5 6 7 8 9] range 5 5 1 => [] range 5 3 1 => [] range 0 10 2 => [0 2 4 6 8]
Given two sorted lists, the result is a list that contains elements of both of the list in result sorted order (using <=), preferring the first list.
Example:
merge [1 3 4 7 8 9] [2 5 6 10 11 12] => [1 2 3 4 5 6 7 8 9 10 11 12]
Given two sorted lists, the result is a list that contains elements of both of the list in result sorted order (using lessEqualComparer), preferring the first list.
Example:
mergeBy (<=) [1 3 4 7 8 9] [2 5 6 10 11 12] => [1 2 3 4 5 6 7 8 9 10 11 12]
Given two sorted lists, the result is a sorted list that contains elements of list in result sorted order (using <=).
Example:
mergeSort [5 4 3 2 1] => [1 2 3 4 5]
Given two sorted lists, the result is a sorted list that contains elements of list in result sorted order (using lessEqualComparator).
Example:
mergeSortBy (<=) [5 4 3 2 1] => [1 2 3 4 5]
Result is a list where each element is mapper applied to the element of the original list, in order.
Example:
define square \x x*x map square [1 2 3] => [1 4 9]
Result is a list of elements of list where keep? element is true.
Example:
filter (2<) [1 2 3 4] => [3 4]
Result is a list of (f (one element of list1) (one element of list2), until at least one of the lists runs out of elements.
Example:
zipBy (+) [1 2 3] [4 5] 0> [5 7]
Associates list elements to the right, two by two, mediated by f, until running out of elements. For the missing element, substitutes v.
Example:
foldr (+) 0 [1 2 3] => (1+(2+(3+0))) => 6 foldr (-) 0 [1 2 3] => (1-(2-(3-0))) => 2
Associates list elements to the left, two by two, mediated by f, until running out of elements. For the missing element, substitutes v.
Example:
foldl (+) 0 [1 2 3] => (((0+1)+2)+3) => 6 foldl (-) 0 [1 2 3] => (((0-1)-2)-3)) => (-6)
Whether all of the elements of the list list satisfy the predicate f.
Whether any of the elements of the list list satisfy the predicate f.