Collection S

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.

#: % -> 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 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.

convert: % -> InputForm if S has ConvertibleTo InputForm

from ConvertibleTo InputForm

copy: % -> %

from Aggregate

count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate

from HomogeneousAggregate S

count: (S, %) -> NonNegativeInteger if % has finiteAggregate and S has BasicType

from HomogeneousAggregate S

empty?: % -> Boolean

from Aggregate

empty: () -> %

from Aggregate

eq?: (%, %) -> Boolean

from Aggregate

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 first x in u such that p(x) is true, 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 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: ((S, S) -> S, %, S) -> S if % has finiteAggregate

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: ((S, S) -> S, %, S, S) -> S if % has finiteAggregate and S has BasicType

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: (S -> Boolean, %) -> % if % has finiteAggregate

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)].

remove: (S, %) -> % if % has finiteAggregate and S has BasicType

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].

removeDuplicates: % -> % if % has finiteAggregate and S has BasicType

removeDuplicates(u) returns a copy of u with all duplicates removed.

sample: %

from Aggregate

select: (S -> Boolean, %) -> % if % has finiteAggregate

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)].

size?: (%, NonNegativeInteger) -> Boolean

from Aggregate

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

HomogeneousAggregate S

InnerEvalable(S, S) if S has SetCategory and S has Evalable S

SetCategory if S has SetCategory