# HomogeneousAggregate SΒΆ

aggcat.spad line 56 [edit on github]

S: Type

A homogeneous aggregate is an aggregate of elements all of the same type. In the current system, all aggregates are homogeneous. Two attributes characterize classes of aggregates. Aggregates from domains with attribute finiteAggregate have a finite number of members. Of course, such a domain may have an infinite number of elements, like, for example List. Those domains with attribute shallowlyMutable allow an element to be modified or updated without changing its overall value.

- #: % -> NonNegativeInteger if % has finiteAggregate
from Aggregate

- =: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has BasicType
from BasicType

- ~=: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has BasicType
from BasicType

- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
`any?(p, u)`

tests if`p(x)`

is`true`

for any element`x`

of`u`

. Note: for collections,`any?(p, u) = reduce(or, map(p, u), false, true)`

. However,`any?(p, u)`

returns as soon as it finds an element for which`p`

gives`true`

.

- coerce: % -> OutputForm if S has CoercibleTo OutputForm
from CoercibleTo OutputForm

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

returns the number of elements`x`

in`u`

such that`p(x)`

is`true`

. For collections,`count(p, u) = reduce(+, [1 for x in u | p(x)], 0)`

.

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

returns the number of occurrences of`x`

in`u`

. For collections,`count(x, u) = reduce(+, [1 for y in u | x = y], 0)`

.

- 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
`every?(p, u)`

tests if`p`

(`x`

) is`true`

for all elements`x`

of`u`

. Note: for collections,`every?(p, u) = reduce(and, map(p, u), true, false)`

. However,`every?(p, u)`

returns as soon as it finds an element for which`p`

gives`false`

.

- 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, %) -> % if % has shallowlyMutable
`map!(f, u)`

destructively replaces each element`x`

of`u`

by`f(x)`

.

- map: (S -> S, %) -> %
`map(f, u)`

returns a copy of`u`

with each element`x`

replaced by`f`

(`x`

). For collections,`map(f, u) = [f(x) for x in u]`

.

- max: % -> S if S has OrderedSet and % has finiteAggregate
`max(u)`

returns maximal element of`u`

. Error if`u`

is empty.

- max: ((S, S) -> Boolean, %) -> S if % has finiteAggregate
`max(p, u)`

returns maximal element of`u`

with respect to total ordering predicate`p`

. Error if`u`

is empty.

- member?: (S, %) -> Boolean if % has finiteAggregate and S has BasicType
`member?(x, u)`

tests if`x`

is a member of`u`

. For collections,`member?(x, u) = reduce(or, [x=y for y in u], false)`

. However,`member?(x, u)`

returns as soon as it finds a member.

- members: % -> List S if % has finiteAggregate
`members(u)`

returns a list of the consecutive elements of`u`

. For multisets members gives result with no repetition. See also parts.

- min: % -> S if S has OrderedSet and % has finiteAggregate
`min(u)`

returns minimal element of`u`

. Error if`u`

is empty.

- more?: (%, NonNegativeInteger) -> Boolean
from Aggregate

- parts: % -> List S if % has finiteAggregate
`parts(u)`

returns a list of the consecutive elements of`u`

. For finite collections,`construct(parts(u)) = u`

.

- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate

BasicType if S has SetCategory or % has finiteAggregate and S has BasicType

CoercibleTo OutputForm if S has CoercibleTo OutputForm

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