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 S has BasicType and % has finiteAggregate
from BasicType
- ~=: (%, %) -> Boolean if S has SetCategory or S has BasicType and % has finiteAggregate
from BasicType
- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
any?(p, u)
tests ifp(x)
istrue
for any elementx
ofu
. 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 whichp
givestrue
.
- coerce: % -> OutputForm if S has CoercibleTo OutputForm
from CoercibleTo OutputForm
- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
count(p, u)
returns the number of elementsx
inu
such thatp(x)
istrue
. For collections,count(p, u) = reduce(+, [1 for x in u | p(x)], 0)
.
- count: (S, %) -> NonNegativeInteger if S has BasicType and % has finiteAggregate
count(x, u)
returns the number of occurrences ofx
inu
. For collections,count(x, u) = reduce(+, [1 for y in u | x = y], 0)
.
- 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
every?(p, u)
tests ifp
(x
) istrue
for all elementsx
ofu
. 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 whichp
givesfalse
.
- 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 elementx
ofu
byf(x)
.
- map: (S -> S, %) -> %
map(f, u)
returns a copy ofu
with each elementx
replaced byf
(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 ofu
. Error ifu
is empty.
- max: ((S, S) -> Boolean, %) -> S if % has finiteAggregate
max(p, u)
returns maximal element ofu
with respect to total ordering predicatep
. Error ifu
is empty.
- member?: (S, %) -> Boolean if S has BasicType and % has finiteAggregate
member?(x, u)
tests ifx
is a member ofu
. 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 ofu
. 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 ofu
. Error ifu
is empty.
- more?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- parts: % -> List S if % has finiteAggregate
parts(u)
returns a list of the consecutive elements ofu
. For finite collections,construct(parts(u)) = u
.
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
BasicType if S has SetCategory or S has BasicType and % has finiteAggregate
CoercibleTo OutputForm if S has CoercibleTo OutputForm
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