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 % has finiteAggregate and S has BasicType or S has SetCategory
from BasicType
- ~=: (%, %) -> Boolean if % has finiteAggregate and S has BasicType 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, ..., zordered as given. Equivalently written as[x, y, ..., z]\$D, whereDis the domain.Dmay 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 % has finiteAggregate and S has BasicType
from HomogeneousAggregate S
- eval: (%, Equation S) -> % if S has SetCategory and S has Evalable S
from Evalable S
- eval: (%, List Equation S) -> % if S has SetCategory and S has Evalable S
from Evalable S
- eval: (%, List S, List S) -> % if S has SetCategory and S has Evalable S
from InnerEvalable(S, S)
- eval: (%, S, S) -> % if S has SetCategory and S has Evalable S
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 firstxinusuch 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 % has finiteAggregate and S has BasicType
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 operationfacrossu. For example, ifuis[x, y, ..., z]thenreduce(f, u)returnsf(..f(f(x, y), ...), z). Note: ifuhas one elementx,reduce(f, u)returnsx. Error: ifuis empty.
- reduce: ((S, S) -> S, %, S) -> S if % has finiteAggregate
reduce(f, u, x)reduces the binary operationfacrossu, wherexis the identity operation off. Same asreduce(f, u)ifuhas 2 or more elements. Returnsf(y, x)ifuhas one elementy. Returnsxifuis empty. For example,reduce(+, u, 0)returns the sum of the elements ofu.
- reduce: ((S, S) -> S, %, S, S) -> S if % has finiteAggregate and S has BasicType
reduce(f, u, x, z)reduces the binary operationfacrossu, stopping when an “absorbing element”zis encountered. As forreduce(f, u, x),xis the identity element off. Same asreduce(f, u, x)whenucontains no elementz. Thus the third argumentxis returned whenuis empty.
- remove: (S -> Boolean, %) -> % if % has finiteAggregate
remove(p, u)returns a copy ofuremoving all elementsxsuch thatp(x)istrue. Note:remove(p, u) = [x for x in u | not p(x)].
- remove: (S, %) -> % if % has finiteAggregate and S has BasicType
remove(x, u)returns a copy ofuwith all elements equal toxremoved. Note:remove(x, u) = [y for y in u | y ~= x].
- removeDuplicates: % -> % if % has finiteAggregate and S has BasicType
removeDuplicates(u)returns a copy ofuwith all duplicates removed.
- select: (S -> Boolean, %) -> % if % has finiteAggregate
select(p, u)returns a copy ofucontaining only those elements suchp(x)istrue. Note:select(p, u) = [x for x in u | p(x)].
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
BasicType if % has finiteAggregate and S has BasicType or S has SetCategory
CoercibleTo OutputForm if S has CoercibleTo OutputForm
ConvertibleTo InputForm if S has ConvertibleTo InputForm
Evalable S if S has SetCategory and S has Evalable S
InnerEvalable(S, S) if S has SetCategory and S has Evalable S
SetCategory if S has SetCategory