# Collection SΒΆ

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

- =: (%, %) -> 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
- 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, %) -> NonNegativeInteger if S has BasicType and % has finiteAggregate
- from HomogeneousAggregate S
- empty: () -> %
- from Aggregate
- empty?: % -> Boolean
- from Aggregate
- eq?: (%, %) -> Boolean
- from Aggregate
- 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)

- find: (S -> Boolean, %) -> Union(S, failed)
`find(p, u)`

returns the first`x`

in`u`

such that`p(x)`

is`true`

, and “failed” otherwise.- hash: % -> SingleInteger if S has SetCategory
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState if S has SetCategory
- from SetCategory
- latex: % -> String if S has SetCategory
- from SetCategory
- less?: (%, NonNegativeInteger) -> Boolean
- from Aggregate
- map: (S -> S, %) -> %
- from HomogeneousAggregate S
- member?: (S, %) -> Boolean if S has BasicType and % has finiteAggregate
- from HomogeneousAggregate S
- more?: (%, NonNegativeInteger) -> Boolean
- from Aggregate

- reduce: ((S, S) -> S, %, S, S) -> S if S has BasicType and % has finiteAggregate
`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, %) -> % if S has BasicType and % has finiteAggregate
`remove(x, u)`

returns a copy of`u`

with all elements equal to`x`

removed. Note:`remove(x, c) == [y for y in c | y ~= x]`

.

- removeDuplicates: % -> % if S has BasicType and % has finiteAggregate
`removeDuplicates(u)`

returns a copy of`u`

with all duplicates removed.- sample: %
- from Aggregate
- 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