This module contains basic functionality for manipulating lists.
Strategy summary
|
|
at-end(Strategy s)
|
Apply s to the Nil of a list
|
common.str
|
|
at-init(Strategy s1, Strategy s2)
|
Applies s1 to all elements in a list, except the last, where s2 is applied
|
common.str
|
|
at-last(Strategy s)
|
Apply s to the last Cons ([_]) of a list
|
common.str
|
|
at-suffix(Strategy s)
|
Apply a strategy to some suffix of a list
|
common.str
|
|
at-suffix-rev(Strategy s)
|
Apply a strategy to some suffix of a list
|
common.str
|
|
at-tail(Strategy s)
|
Apply a strategy to the tail of a list
|
common.str
|
|
back-split-at(ATerm n)
|
Splits a list in two, with the second part containing the last n elements and and first part containing all elements except the last n
|
common.str
|
|
common-prefix
|
Returns the common prefix of two lists
|
common.str
|
|
conc
|
Concatenates all lists of a tuple
|
common.str
|
|
concat
|
Concatenates a list of lists into one list
|
common.str
|
|
copy
|
n/a
|
common.str
|
|
copy(Strategy s)
|
Makes n copies of a term into a list of duplicates, applying the strategy s to every copy
|
common.str
|
|
drop(ATerm n)
|
Drops the first n elements from a list
|
common.str
|
|
drop(Strategy isn)
|
Drops a number of terms from the front of a list
|
common.str
|
|
drop-until(Strategy s)
|
Drops elements from the start of a list until s succeeds
|
common.str
|
|
drop-while(Strategy s)
|
Drops elements from the start of a list while s succeeds
|
common.str
|
|
elem
|
Succeeds if the term is in the list
|
common.str
|
|
elem(Strategy eq)
|
Succeeds if the term is in the list, using the given strategy for determining equality
|
common.str
|
|
eliminate-common-suffix
|
Eliminates all elements at the end of the two lists that are equal
|
common.str
|
|
fetch(Strategy s)
|
Find first list element for which s succeeds
|
common.str
|
|
fetch-elem(Strategy s)
|
Return first list element for which s succeeds
|
common.str
|
|
first-last
|
Returns a list with the first and the last element of the input list
|
common.str
|
|
flatten-list
|
Completely flattens a list and its sublists to a single list
|
common.str
|
|
foldl(Strategy s)
|
Left folds a list
|
common.str
|
|
foldr(Strategy s1, Strategy s2)
|
Right folds a list
|
common.str
|
|
foldr(Strategy s1, Strategy s2, Strategy f)
|
Right folds a list
|
common.str
|
|
for-each-pair(Strategy s)
|
n/a
|
common.str
|
|
init
|
n/a
|
common.str
|
|
is-list
|
Succeeds if the input term is a list
|
common.str
|
|
last
|
Returns the last element of a list
|
common.str
|
|
length
|
Returns the length of a list
|
common.str
|
|
list(Strategy s)
|
n/a
|
common.str
|
|
list-combinations
|
Returns a list of combinations by choosing one element from every list, in every possible combination
|
common.str
|
|
list-fold(Strategy s, ATerm acc)
|
n/a
|
common.str
|
|
list-loop(Strategy s)
|
Iterative loop over a list applying s to each element
|
common.str
|
|
list-some(Strategy s)
|
Apply a strategy to some elements in a list
|
common.str
|
|
list-tokenize(ATerm sep)
|
Breaks a list into multiple parts (tokens)
|
common.str
|
|
list-tokenize(Strategy sep)
|
Breaks a list into multiple parts (tokens)
|
common.str
|
|
listbu(Strategy s)
|
Applies a strategy to a list in bottom up order
|
common.str
|
|
listbu1(Strategy s)
|
n/a
|
common.str
|
|
listdu(Strategy s)
|
n/a
|
common.str
|
|
listdu2(Strategy s1, Strategy s2)
|
n/a
|
common.str
|
|
listtd(Strategy s)
|
n/a
|
common.str
|
|
ltrim(Strategy s)
|
n/a
|
common.str
|
|
makeConc
|
Concats two elements if both elements are lists
|
common.str
|
|
map(Strategy s)
|
Apply a strategy to each element of a list
|
common.str
|
|
mapconcat(Strategy s)
|
Transform the elements of a list into lists (map) and concatenate into a single list (concat)
|
common.str
|
|
matrix-transpose
|
Transposes an n by m matrix
|
common.str
|
|
member
|
Succeeds if the first input term is a member of the second
|
common.str
|
|
number(Strategy s)
|
n/a
|
common.str
|
|
reverse
|
Reverses a list
|
common.str
|
|
reverse(Strategy s)
|
Reverses a list and applies s to all the elements
|
common.str
|
|
reverse-map(Strategy s)
|
In reverse order, apply a strategy to each element of a list
|
common.str
|
|
rtrim(Strategy s)
|
Trim elements from the end of a list
|
common.str
|
|
separate-by
|
Separates the elements of the list by the specified separator
|
common.str
|
|
separate-by(Strategy sep)
|
Separates the elements of the list by the specified separator
|
common.str
|
|
separate-by(ATerm sep)
|
Separates the elements of the list by the specified separator
|
common.str
|
|
split-at(Strategy s)
|
n/a
|
common.str
|
|
split-at(ATerm n)
|
Splits the list in two sublists, containing elements from 0 to n and from n onwards
|
common.str
|
|
split-fetch(Strategy s)
|
Splits a list in two parts at the first point where s succeeds
|
common.str
|
|
split-fetch-keep(Strategy s)
|
Splits a list in two parts at the point where s succeeds, keeping the element at which s succeeded
|
common.str
|
|
split-init-last
|
Splits a list into a tuple of its init list and last element
|
common.str
|
|
split-last
|
n/a
|
common.str
|
|
splitmap(Strategy s, ATerm n)
|
Splits a list after n elements and applies strategy s to the first sublist
|
common.str
|
|
take(Strategy isn)
|
Take the first n elements of a list, given by isn
|
common.str
|
|
take(ATerm n)
|
Returns the first n elements of a list, fails if list has fewer than n elements
|
common.str
|
|
take-until(Strategy s)
|
Take elements from the start of a list until s succeeds
|
common.str
|
|
take-while(Strategy s)
|
Take elements from the start of a list while s succeeds
|
common.str
|
|
takemap(Strategy s, ATerm n)
|
Returns the n first elements after s has been applied to them
|
common.str
|
|
trim(Strategy s)
|
Trim elements from both start and end of a list
|
common.str
|
|
upto
|
n/a
|
common.str
|
Strategy details
|
|
ATerm
|
at-end(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s
|
is applied to Nil ([]) and must return a list: List(a) -> List(a)
|
|
Apply s to the Nil of a list.
|
|
|
|
ATerm
|
at-init(Strategy s1, Strategy s2)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s1
|
s1 a -> b
|
|
Strategy
s2
|
s2 a -> b
|
|
Applies s1 to all elements in a list, except the last, wheres2 is applied.
|
|
|
|
ATerm
|
at-last(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s
|
Is applied to the [x] and must return a list: List(a) -> List(a)
|
|
Apply s to the last Cons ([_]) of a list.
|
|
|
|
ATerm
|
at-suffix(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s
|
is applied to the suffix : List(a) -> b
|
|
Apply a strategy to some suffix of a list.
The longest suffix (that is, the first application in a list)is preferred.
|
type
|
List(a) -> List(a or b)
|
|
|
|
|
ATerm
|
at-suffix-rev(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s
|
is applied to the suffix : List(a) -> b
|
|
Apply a strategy to some suffix of a list.
The shortest suffix (that is, the last application in a list)is preferred.
|
type
|
List(a) -> List(a or b)
|
|
|
|
|
ATerm
|
at-tail(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Strategy
s
|
is applied to the tail: List(a) -> List(b)
|
|
Apply a strategy to the tail of a list.
|
type
|
List(a) -> List(a or b)
|
|
|
|
|
ATerm
|
back-split-at(ATerm n)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
ATerm
n
|
n - the number of elements to split at (counting from the back)
|
|
Splits a list in two, with the second part containing the lastn elements and and first part containing all elements except thelast n.
|
type
|
List(a) -> (List(a), List(a))
|
|
|
|
|
ATerm
|
common-prefix
|
Returns the common prefix of two lists.
Examples:<common-prefix>([1,2,3], [1,2,4,5]) => [1,2]<common-prefix>([1,2,3], [2,3,4]) => []
|
type
|
(List(a), List(a)) -> List(a)
|
|
|
|
|
ATerm
|
conc
|
Concatenates all lists of a tuple.
|
type
|
(List(a), List(a), ...) -> List(a)
|
|
|
|
|
ATerm
|
concat
|
Concatenates a list of lists into one list.
Example: <concat> [[1,2],[3,4],[5,6]] => [1,2,3,4,5,6]
|
type
|
List(List(a)) -> List(a)
|
|
|
|
|
ATerm
|
copy(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Makes n copies of a term into a list of duplicates, applyingthe strategy s to every copy. The first input term is the integer n, the second is the term to duplicate.
Example: <copy(\ "foo" -> "bar" \)> (3, "foo") => ["bar","bar,"bar"]
|
|
|
|
ATerm
|
drop(ATerm n)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
ATerm
n
|
n - the number of elements to drop
|
|
Drops the first n elements from a list. If the list hasfewer than n elements, the strategy fails.
|
|
|
|
ATerm
|
drop(Strategy isn)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Drops a number of terms from the front of a list.
The number is specified by the strategy argument, which shouldproduce an integer.
|
|
|
|
ATerm
|
drop-until(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Drops elements from the start of a list until s succeeds. Thefirst element at which s succeeds and all following it will bereturned.
Example: <drop-until(?3)> [2,2,3,4] => [3,4]
|
|
|
|
ATerm
|
drop-while(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Drops elements from the start of a list while s succeeds. Thefirst element at which s fails and all following it will bereturned.
Example: <drop-while(?2)> [2,2,3,4] => [3,4]
|
|
|
|
ATerm
|
elem
|
Succeeds if the term is in the list.
|
type
|
(a, List(a)) ->? List(a)
|
|
|
|
|
ATerm
|
elem(Strategy eq)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Succeeds if the term is in the list, using the givenstrategy for determining equality.
|
type
|
(a, List(a)) ->? List(a or b)
|
|
|
|
|
ATerm
|
eliminate-common-suffix
|
Eliminates all elements at the end of the two lists that are equal.Only works correctly on lists of equal length!
Example: <eliminate-common-suffix>([1,3,4], [1,2,4]) => ([1,3], [1,2])
|
type
|
(List(a), List(a)) -> (List(a), List(a))
|
|
|
|
|
ATerm
|
fetch(Strategy s)
|
|
File
|
common.str
|
|
Author
|
unknown
|
|
Since
|
unknown
|
|
|
Parameters
|
Find first list element for which s succeeds.
|
type
|
List(a) -> List(a or b)
|
|
|
|
|
ATerm
|
fetch-elem(Strategy s)
|
Return first list element for which s succeeds.
|
|
|
|
ATerm
|
first-last
|
Returns a list with the first and the last element ofthe input list. For the empty list and the singletonlist, this is equivalent to id.
|
|
|
|
ATerm
|
flatten-list
|
|
|