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 ifuhas 0 elements.
- empty: () -> %
empty()$Dcreates an aggregate of typeDwith 0 elements. Note: The $D can be dropped if understood by context, e.g.u: D := empty().
- eq?: (%, %) -> Boolean
eq?(u, v)tests ifuandvare same objects.
- less?: (%, NonNegativeInteger) -> Boolean
less?(u, n)tests ifuhas less thannelements.
- more?: (%, NonNegativeInteger) -> Boolean
more?(u, n)tests ifuhas more thannelements.
- sample: %
sample yieldsa value of type %
- size?: (%, NonNegativeInteger) -> Boolean
size?(u, n)tests ifuhas exactlynelements.