aggcat.spad line 182 [edit on github]
A collection is a homogeneous aggregate which can be built from a list of members. The operation used to build the aggregate is generically named construct. However, each collection provides its own special function with the same name as the data type, except with an initial lower case letter, e.g. list for List, flexibleArray for FlexibleArray, and so on.
construct([x, y, ..., z])
returns the collection of elements x, y, ..., z
ordered as given. Equivalently written as [x, y, ..., z]$D
, where D
is the domain. D
may be omitted for those of type List.
find(p, u)
returns the first x
in u
such that p(x)
is true
, and "failed" otherwise.
reduce(f, u)
reduces the binary operation f
across u
. For example, if u
is [x, y, ..., z]
then reduce(f, u)
returns f(..f(f(x, y), ...), z)
. Note: if u
has one element x
, reduce(f, u)
returns x
. Error: if u
is empty.
reduce(f, u, x)
reduces the binary operation f
across u
, where x
is the identity operation of f
. Same as reduce(f, u)
if u
has 2 or more elements. Returns f(y, x)
if u
has one element y
. Returns x
if u
is empty. For example, reduce(+, u, 0)
returns the sum of the elements of u
.
reduce(f, u, x, z)
reduces the binary operation f
across u
, stopping when an "absorbing element" z
is encountered. As for reduce(f, u, x)
, x
is the identity element of f
. Same as reduce(f, u, x)
when u
contains no element z
. Thus the third argument x
is returned when u
is empty.
remove(x, u)
returns a copy of u
with all elements equal to x
removed. Note: remove(x, u) = [y for y in u | y ~= x]
.
remove(p, u)
returns a copy of u
removing all elements x
such that p(x)
is true
. Note: remove(p, u) = [x for x in u | not p(x)]
.
removeDuplicates(u)
returns a copy of u
with all duplicates removed.
select(p, u)
returns a copy of u
containing only those elements such p(x)
is true
. Note: select(p, u) = [x for x in u | p(x)]
.
InnerEvalable(S, S)
Evalable(S)