# RecursiveAggregate SΒΆ

aggcat.spad line 1046 [edit on github]

S: Type

A recursive aggregate over a type `S`

is a model for a a directed graph containing values of type `S`

. Recursively, a recursive aggregate is either empty or a *node* consisting of a value from `S`

and 0 or more children which are also nodes. A node with no children is called a leaf node. A recursive aggregate may be cyclic for which some operations as noted may go into an infinite loop.

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

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

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

- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate S

- children: % -> List %
`children(u)`

returns a list of the children of aggregate`u`

. Error: if`u`

is empty.

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

- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
from HomogeneousAggregate S

- count: (S, %) -> NonNegativeInteger if % has finiteAggregate and S has BasicType
from HomogeneousAggregate S

- cyclic?: % -> Boolean
`cyclic?(u)`

tests if`u`

has a cycle.

- distance: (%, %) -> Integer
`distance(u, v)`

returns the path length (an integer) from node`u`

to`v`

.

- elt: (%, value) -> S
`elt(u, "value")`

(also written:`u.value`

) is equivalent to`value(u)`

.

- 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
from HomogeneousAggregate S

- latex: % -> String if S has SetCategory
from SetCategory

- leaf?: % -> Boolean
`leaf?(u)`

tests if`u`

is a terminal node.

- leaves: % -> List S
`leaves(u)`

returns the list of leaves in aggregate`u`

.

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

- map!: (S -> S, %) -> % if % has shallowlyMutable
from HomogeneousAggregate S

- map: (S -> S, %) -> %
from HomogeneousAggregate S

- max: % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate S

- max: ((S, S) -> Boolean, %) -> S if % has finiteAggregate
from HomogeneousAggregate S

- member?: (S, %) -> Boolean if % has finiteAggregate and S has BasicType
from HomogeneousAggregate S

- members: % -> List S if % has finiteAggregate
from HomogeneousAggregate S

- min: % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate S

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

- node?: (%, %) -> Boolean if S has BasicType
`node?(u, v)`

tests if node`u`

is contained in node`v`

(either as a child, a child of a child, etc.).

- nodes: % -> List %
`nodes(u)`

returns a list of all of the nodes of aggregate`u`

.

- parts: % -> List S if % has finiteAggregate
from HomogeneousAggregate S

- setchildren!: (%, List %) -> % if % has shallowlyMutable
`setchildren!(u, v)`

replaces the current children of node`u`

with the members of`v`

in left-to-right order.

- setelt!: (%, value, S) -> S if % has shallowlyMutable
`setelt!(u, "value", x)`

(also written`u.value := x`

) is equivalent to`setvalue!(u, x)`

- setvalue!: (%, S) -> S if % has shallowlyMutable
`setvalue!(u, x)`

sets the value of node`u`

to`x`

.

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

- value: % -> S
`value(u)`

returns the value of the node`u`

.

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

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