UnaryRecursiveAggregate SΒΆ

aggcat.spad line 1278

A unary-recursive aggregate is an aggregate where nodes may have either 0 or 1 children. This aggregate models, though not precisely, a linked list possibly with a single cycle. A node with one children models a non-empty list, with the value of the list designating the head, or first, of the list, and the child designating the tail, or rest, of the list. A node with no child then designates the empty list. Since these aggregates are recursive aggregates, they may be cyclic.

=: (%, %) -> Boolean if S has SetCategory or S has BasicType and % has finiteAggregate
from BasicType
~=: (%, %) -> Boolean if S has SetCategory or S has BasicType and % has finiteAggregate
from BasicType
child?: (%, %) -> Boolean if S has BasicType
from RecursiveAggregate S
children: % -> List %
from RecursiveAggregate S
coerce: % -> OutputForm if S has CoercibleTo OutputForm
from CoercibleTo OutputForm
concat: (%, %) -> %
concat(u, v) returns an aggregate w consisting of the elements of u followed by the elements of v. Note: v = rest(w, \#a).
concat: (S, %) -> %
concat(x, u) returns aggregate consisting of x followed by the elements of u. Note: if v = concat(x, u) then x = first v and u = rest v.
copy: % -> %
from Aggregate
count: (S, %) -> NonNegativeInteger if S has BasicType and % has finiteAggregate
from HomogeneousAggregate S
cycleEntry: % -> %
cycleEntry(u) returns the head of a top-level cycle contained in aggregate u, or empty() if none exists.
cycleLength: % -> NonNegativeInteger
cycleLength(u) returns the length of a top-level cycle contained in aggregate u, or 0 is u has no such cycle.
cycleTail: % -> %
cycleTail(u) returns the last node in the cycle, or empty if none exists.
cyclic?: % -> Boolean
from RecursiveAggregate S
distance: (%, %) -> Integer
from RecursiveAggregate S
elt: (%, first) -> S
elt(u,"first") (also written: u . first) is equivalent to first u.
elt: (%, last) -> S
elt(u,"last") (also written: u . last) is equivalent to last u.
elt: (%, rest) -> %
elt(\%,"rest") (also written: u.rest) is equivalent to rest u.
elt: (%, value) -> S
from RecursiveAggregate S
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)
first: % -> S
first(u) returns the first element of u (equivalently, the value at the current node).
first: (%, NonNegativeInteger) -> %
first(u, n) returns a copy of the first n (n >= 0) elements of u.
hash: % -> SingleInteger if S has SetCategory
from SetCategory
hashUpdate!: (HashState, %) -> HashState if S has SetCategory
from SetCategory
last: % -> S
last(u) returns the last element of u. Note: for lists, last(u) = u . (maxIndex u) = u . (\# u - 1).
last: (%, NonNegativeInteger) -> %
last(u, n) returns a copy of the last n (n >= 0) nodes of u. Note: last(u, n) is a list of n elements.
latex: % -> String if S has SetCategory
from SetCategory
leaf?: % -> Boolean
from RecursiveAggregate S
leaves: % -> List S
from RecursiveAggregate S
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
from RecursiveAggregate S
nodes: % -> List %
from RecursiveAggregate S
rest: % -> %
rest(u) returns an aggregate consisting of all but the first element of u (equivalently, the next node of u).
rest: (%, NonNegativeInteger) -> %
rest(u, n) returns the nth (n >= 0) node of u. Note: rest(u, 0) = u.
sample: %
from Aggregate
second: % -> S
second(u) returns the second element of u. Note: second(u) = first(rest(u)).
size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
tail: % -> %
tail(u) returns the last node of u. Note: if u is shallowlyMutable, setrest(tail(u), v) = concat(u, v).
third: % -> S
third(u) returns the third element of u. Note: third(u) = first(rest(rest(u))).
value: % -> S
from RecursiveAggregate S

Aggregate

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

CoercibleTo OutputForm if S has CoercibleTo OutputForm

Evalable S if S has Evalable S and S has SetCategory

HomogeneousAggregate S

InnerEvalable(S, S) if S has Evalable S and S has SetCategory

RecursiveAggregate S

SetCategory if S has SetCategory