Aggregate¶
aggcat.spad line 1 [edit on github]
The notion of aggregate serves to model any data structure aggregate, designating any collection of objects, with heterogeneous or homogeneous members, with a finite or infinite number of members, explicitly or implicitly represented. An aggregate can in principle represent everything from a string of characters to abstract sets such as “the set of x
satisfying relation r(x)“. An attribute finiteAggregate is used to assert that a domain has a finite number of elements.
- #: % -> NonNegativeInteger if % has finiteAggregate
\#(u)
returns the number of elements inu
.
- copy: % -> %
copy(u)
returns a top-level (non-recursive) copy ofu
. Note: for collections,copy(u) = [x for x in u]
.
- empty?: % -> Boolean
empty?(u)
tests ifu
has 0 elements.
- empty: () -> %
empty()
$D
creates an aggregate of typeD
with 0 elements. Note: The $D can be dropped if understood by context, e.g.u: D := empty()
.
- eq?: (%, %) -> Boolean
eq?(u, v)
tests ifu
andv
are same objects.
- less?: (%, NonNegativeInteger) -> Boolean
less?(u, n)
tests ifu
has less thann
elements.
- more?: (%, NonNegativeInteger) -> Boolean
more?(u, n)
tests ifu
has more thann
elements.
- sample: %
sample yields
a value of type %
- size?: (%, NonNegativeInteger) -> Boolean
size?(u, n)
tests ifu
has exactlyn
elements.