aggcat.spad line 56 [edit on github]
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.
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
.
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)
.
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)
.
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
.
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]
.
map!(f, u)
destructively replaces each element x
of u
by f(x)
.
max(u)
returns maximal element of u
. Error if u
is empty.
max(p, u)
returns maximal element of u
with respect to total ordering predicate p
. Error if u
is empty.
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(u)
returns a list of the consecutive elements of u
. For multisets members gives result with no repetition. See also parts.
min(u)
returns minimal element of u
. Error if u
is empty.
parts(u)
returns a list of the consecutive elements of u
. For finite collections, construct(parts(u)) = u
.
InnerEvalable(S, S)
Evalable(S)