UnaryRecursiveAggregate S¶
aggcat.spad line 1296 [edit on github]
S: Type
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. Since these aggregates are recursive aggregates, they may be cyclic.
- #: % -> NonNegativeInteger if % has finiteAggregate
from Aggregate
- =: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has BasicType
from BasicType
- ~=: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has BasicType
from BasicType
- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate S
- 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!: (%, %) -> % if % has shallowlyMutable
concat!(u, v)destructively concatenatesvto the end ofu.
- concat!: (%, S) -> % if % has shallowlyMutable
concat!(u, x)destructively adds elementxto the end ofu. Note:concat!(a, x) = concat!(a, [x]).
- concat!: List % -> % if % has shallowlyMutable
concat!(lu), whereluis a list of aggregates[a, b, ..., c], returns a single aggregate consisting of the elements ofafollowed by those ofbfollowed … by the elements ofc. This function may destructively modify the aggregates inlu.
- concat: (%, %) -> %
concat(u, v)returns an aggregatewconsisting of the elements ofufollowed by the elements ofv. Note:v = rest(w, \#u).
- concat: (S, %) -> %
concat(x, u)returns aggregate consisting ofxfollowed by the elements ofu. Note: ifv = concat(x, u)thenx = first vandu = rest v.
- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
from HomogeneousAggregate S
- count: (S, %) -> NonNegativeInteger if % has finiteAggregate and S has BasicType
from HomogeneousAggregate S
- cycleEntry: % -> %
cycleEntry(u)returns the head of a top-level cycle contained in aggregateu, orempty()if none exists.
- cycleLength: % -> NonNegativeInteger
cycleLength(u)returns the length of a top-level cycle contained in aggregateu, or 0 ifuhas no such cycle.
- cycleSplit!: % -> % if % has shallowlyMutable
cycleSplit!(u)splits the aggregate by dropping off the cycle. The value returned is the cycle entry, or empty() if none exists. For example, ifw = concat(u, v)is the cyclic list wherevis the head of the cycle,cycleSplit!(w)will dropvoffwthus destructively changingwtou, and returningv.
- 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 torest u.- elt: (%, value) -> S
from RecursiveAggregate S
- 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
- first: % -> S
first(u)returns the first element ofu(equivalently, the value at the current node).
- first: (%, NonNegativeInteger) -> %
first(u, n)returns a copy of the firstnelements ofu.
- last: % -> S
last(u)returns the last element ofu. Note: for lists,last(u) = u.(maxIndex u).
- last: (%, NonNegativeInteger) -> %
last(u, n)returns a copy of the lastnnodes ofu. Note:last(u, n)is a list ofnelements.
- 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, %) -> % 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
from RecursiveAggregate S
- nodes: % -> List %
from RecursiveAggregate S
- parts: % -> List S if % has finiteAggregate
from HomogeneousAggregate S
- qsetfirst!: (%, S) -> S if % has shallowlyMutable
qsetfirst!(u, x)destructively changes the first element ofutoxwithout checking for errors.
- qsetrest!: (%, %) -> % if % has shallowlyMutable
qsetrest!(u, v)destructively changes the rest ofutovwithout checking for errors.
- rest: % -> %
rest(u)returns an aggregate consisting of all but the first element ofu(equivalently, the next node ofu).
- rest: (%, NonNegativeInteger) -> %
rest(u, n)returns thenth node ofu. Note:rest(u, 0) = u.
- second: % -> S
second(u)returns the second element ofu. Note:second(u) = first(rest(u)).
- setchildren!: (%, List %) -> % if % has shallowlyMutable
from RecursiveAggregate S
- setelt!: (%, first, S) -> S if % has shallowlyMutable
setelt!(u, "first", x)(also written:u.first := x) is equivalent tosetfirst!(u, x).
- setelt!: (%, last, S) -> S if % has shallowlyMutable
setelt!(u, "last", x)(also written:u.last := x) is equivalent tosetlast!(u, x).
- setelt!: (%, rest, %) -> % if % has shallowlyMutable
setelt!(u, "rest", v)(also written:u.rest := v) is equivalent tosetrest!(u, v).- setelt!: (%, value, S) -> S if % has shallowlyMutable
from RecursiveAggregate S
- setfirst!: (%, S) -> S if % has shallowlyMutable
setfirst!(u, x)destructively changes the first element ofutox. Error ifuis empty.
- setlast!: (%, S) -> S if % has shallowlyMutable
setlast!(u, x)destructively changes the last element ofutox. Error ifuis empty.
- setrest!: (%, %) -> % if % has shallowlyMutable
setrest!(u, v)destructively changes the rest ofutov. Error ifuis empty.
- setvalue!: (%, S) -> S if % has shallowlyMutable
from RecursiveAggregate S
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- split!: (%, NonNegativeInteger) -> % if % has shallowlyMutable
split!(u, n)splitsuinto two aggregates:v = rest(u, n)andw = first(u, n), returningvand settingutow. Ifnis 0, split! currently only works for Stream and gives error for List. Note: afterwardsrest(u, n)returnsempty().
- tail: % -> %
tail(u)returns the last node ofu. Error ifuis empty.
- third: % -> S
third(u)returns the third element ofu. Note:third(u) = first(rest(rest(u))).
- value: % -> S
from RecursiveAggregate S
BasicType if S has SetCategory or % has finiteAggregate and S has BasicType
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