Collection S¶
aggcat.spad line 182 [edit on github]
S: Type
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.
- #: % -> NonNegativeInteger if % has finiteAggregate
from Aggregate
- =: (%, %) -> Boolean if S has BasicType and % has finiteAggregate or S has SetCategory
from BasicType
- ~=: (%, %) -> Boolean if S has BasicType and % has finiteAggregate or S has SetCategory
from BasicType
- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate S
- coerce: % -> OutputForm if S has CoercibleTo OutputForm
from CoercibleTo OutputForm
- construct: List S -> %
construct([x, y, ..., z])
returns the collection of elementsx, y, ..., z
ordered as given. Equivalently written as[x, y, ..., z]\$D
, whereD
is the domain.D
may be omitted for those of type List.
- convert: % -> InputForm if S has ConvertibleTo InputForm
from ConvertibleTo InputForm
- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
from HomogeneousAggregate S
- count: (S, %) -> NonNegativeInteger if S has BasicType and % has finiteAggregate
from HomogeneousAggregate S
- eval: (%, Equation S) -> % if S has Evalable S and S has SetCategory
from Evalable S
- eval: (%, List Equation S) -> % if S has Evalable S and S has SetCategory
from Evalable S
- eval: (%, List S, List S) -> % if S has Evalable S and S has SetCategory
from InnerEvalable(S, S)
- eval: (%, S, S) -> % if S has Evalable S and S has SetCategory
from InnerEvalable(S, S)
- every?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate S
- find: (S -> Boolean, %) -> Union(S, failed)
find(p, u)
returns the firstx
inu
such thatp(x)
istrue
, and “failed” otherwise.
- latex: % -> String if S has SetCategory
from SetCategory
- less?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- map!: (S -> S, %) -> % if % has shallowlyMutable
from HomogeneousAggregate S
- map: (S -> S, %) -> %
from HomogeneousAggregate S
- max: % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate S
- max: ((S, S) -> Boolean, %) -> S if % has finiteAggregate
from HomogeneousAggregate S
- member?: (S, %) -> Boolean if S has BasicType and % has finiteAggregate
from HomogeneousAggregate S
- members: % -> List S if % has finiteAggregate
from HomogeneousAggregate S
- min: % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate S
- more?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- parts: % -> List S if % has finiteAggregate
from HomogeneousAggregate S
- reduce: ((S, S) -> S, %) -> S if % has finiteAggregate
reduce(f, u)
reduces the binary operationf
acrossu
. For example, ifu
is[x, y, ..., z]
thenreduce(f, u)
returnsf(..f(f(x, y), ...), z)
. Note: ifu
has one elementx
,reduce(f, u)
returnsx
. Error: ifu
is empty.
- reduce: ((S, S) -> S, %, S) -> S if % has finiteAggregate
reduce(f, u, x)
reduces the binary operationf
acrossu
, wherex
is the identity operation off
. Same asreduce(f, u)
ifu
has 2 or more elements. Returnsf(y, x)
ifu
has one elementy
. Returnsx
ifu
is empty. For example,reduce(+, u, 0)
returns the sum of the elements ofu
.
- reduce: ((S, S) -> S, %, S, S) -> S if S has BasicType and % has finiteAggregate
reduce(f, u, x, z)
reduces the binary operationf
acrossu
, stopping when an “absorbing element”z
is encountered. As forreduce(f, u, x)
,x
is the identity element off
. Same asreduce(f, u, x)
whenu
contains no elementz
. Thus the third argumentx
is returned whenu
is empty.
- remove: (S -> Boolean, %) -> % if % has finiteAggregate
remove(p, u)
returns a copy ofu
removing all elementsx
such thatp(x)
istrue
. Note:remove(p, u) = [x for x in u | not p(x)]
.
- remove: (S, %) -> % if S has BasicType and % has finiteAggregate
remove(x, u)
returns a copy ofu
with all elements equal tox
removed. Note:remove(x, u) = [y for y in u | y ~= x]
.
- removeDuplicates: % -> % if S has BasicType and % has finiteAggregate
removeDuplicates(u)
returns a copy ofu
with all duplicates removed.
- select: (S -> Boolean, %) -> % if % has finiteAggregate
select(p, u)
returns a copy ofu
containing only those elements suchp(x)
istrue
. Note:select(p, u) = [x for x in u | p(x)]
.
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
BasicType if S has BasicType and % has finiteAggregate or S has SetCategory
CoercibleTo OutputForm if S has CoercibleTo OutputForm
ConvertibleTo InputForm if S has ConvertibleTo InputForm
Evalable S if S has Evalable S and S has SetCategory
InnerEvalable(S, S) if S has Evalable S and S has SetCategory
SetCategory if S has SetCategory