# RecursiveAggregate SΒΆ

- 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 a *node* consisting of a value from `S`

and 0 or more children which are recursive aggregates. 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.

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

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

returns a list of the children of aggregate`u`

.- coerce: % -> OutputForm if S has CoercibleTo OutputForm
- from CoercibleTo OutputForm
- copy: % -> %
- from Aggregate
- count: (S, %) -> NonNegativeInteger if S has BasicType and % has finiteAggregate
- 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:`a. value`

) is equivalent to`value(a)`

.- empty: () -> %
- from Aggregate
- empty?: % -> Boolean
- from Aggregate
- eq?: (%, %) -> Boolean
- from Aggregate
- 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)
- hash: % -> SingleInteger if S has SetCategory
- from SetCategory
- hashUpdate!: (HashState, %) -> HashState if S has SetCategory
- from SetCategory
- latex: % -> String if S has SetCategory
- from SetCategory

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

tests if`u`

is a terminal node.

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

returns the list of values in obtained by visiting the nodes of tree`t`

in left-to-right order.- less?: (%, NonNegativeInteger) -> Boolean
- from Aggregate
- map: (S -> S, %) -> %
- from HomogeneousAggregate S
- member?: (S, %) -> Boolean if S has BasicType 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`

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

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

returns the value of the node`u`

.

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

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