LinearAggregate S¶
aggcat.spad line 1705 [edit on github]
S: Type
A linear aggregate is an aggregate whose elements are indexed by integers. Examples of linear aggregates are strings, lists, and arrays. Most of the exported operations for linear aggregates are non-destructive but are not always efficient for a particular aggregate. For example, concat of two lists needs only to copy its first argument, whereas concat of two arrays needs to copy both arguments. Most of the operations exported here apply to infinite objects (e.g. streams) as well to finite ones. If the aggregate is a finite aggregate then it has several additional exports such as reverse, sort, and so on.
- #: % -> NonNegativeInteger if % has finiteAggregate
from Aggregate
- <=: (%, %) -> Boolean if % has finiteAggregate and S has OrderedSet
from PartialOrder
- <: (%, %) -> Boolean if % has finiteAggregate and S has OrderedSet
from PartialOrder
- =: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has Hashable or % has finiteAggregate and S has BasicType
from BasicType
- >=: (%, %) -> Boolean if % has finiteAggregate and S has OrderedSet
from PartialOrder
- >: (%, %) -> Boolean if % has finiteAggregate and S has OrderedSet
from PartialOrder
- ~=: (%, %) -> Boolean if S has SetCategory or % has finiteAggregate and S has Hashable or % has finiteAggregate and S has BasicType
from BasicType
- any?: (S -> Boolean, %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate S
- coerce: % -> OutputForm if S has CoercibleTo OutputForm
from CoercibleTo OutputForm
- concat: (%, %) -> %
concat(u, v)returns an aggregate consisting of the elements ofufollowed by the elements ofv. Note: ifw = concat(u, v)thenw.i = u.i for i in indices uandw.(j + maxIndex u) = v.j for j in indices v.
- concat: (%, S) -> %
concat(u, x)returns aggregateuwith additional elementxat the end. Note: for lists,concat(u, x) = concat(u, [x]).
- concat: (S, %) -> %
concat(x, u)returns aggregateuwith additional elementxat the front. Note: for lists:concat(x, u) = concat([x], u).
- concat: List % -> %
concat(u), whereuis a list of aggregates[a, b, ..., c], returns a single aggregate consisting of the elements ofafollowed by those ofbfollowed … by the elements ofc. Note:concat([a, b, ..., c]) = concat(a, concat([b, ..., c])).
- construct: List S -> %
from Collection S
- convert: % -> InputForm if S has ConvertibleTo InputForm
from ConvertibleTo InputForm
- copyInto!: (%, %, Integer) -> % if % has finiteAggregate and % has shallowlyMutable
copyInto!(u, v, i)returns aggregateucontaining a copy ofvinserted at elementi.
- count: (S -> Boolean, %) -> NonNegativeInteger if % has finiteAggregate
from HomogeneousAggregate S
- count: (S, %) -> NonNegativeInteger if % has finiteAggregate and S has BasicType
from HomogeneousAggregate S
- delete: (%, Integer) -> %
delete(u, i)returns a copy ofuwith theith element deleted. Note:delete(u, i) = concat(u(minIndex(u)..i - 1), u(i + 1..)).
- delete: (%, UniversalSegment Integer) -> %
delete(u, i..j)returns a copy ofuwith theith throughjth element deleted. Note:delete(u, i..j) = concat(u(minIndex(u)..i-1), u(j+1..)).
- elt: (%, Integer) -> S
- elt: (%, Integer, S) -> S
from EltableAggregate(Integer, S)
- elt: (%, UniversalSegment Integer) -> %
from Eltable(UniversalSegment Integer, %)
- entries: % -> List S
from IndexedAggregate(Integer, S)
- entry?: (S, %) -> Boolean if % has finiteAggregate and S has BasicType
from IndexedAggregate(Integer, 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
- fill!: (%, S) -> % if % has shallowlyMutable
from IndexedAggregate(Integer, S)
- find: (S -> Boolean, %) -> Union(S, failed)
from Collection S
- first: % -> S
from IndexedAggregate(Integer, S)
- first: (%, NonNegativeInteger) -> %
first(u, n)returns a copy of the firstnelements ofu. Error: ifuhas less thannelements.
- hash: % -> SingleInteger if % has finiteAggregate and S has Hashable
from Hashable
- hashUpdate!: (HashState, %) -> HashState if % has finiteAggregate and S has Hashable
from Hashable
- index?: (Integer, %) -> Boolean
from IndexedAggregate(Integer, S)
- indices: % -> List Integer
from IndexedAggregate(Integer, S)
- insert: (%, %, Integer) -> %
insert(v, u, i)returns a copy ofuhavingvinserted beginning at theith element. Note:insert(v, u, i) = concat(u(minIndex(u)..i-1), concat(v, u(i..))).
- insert: (S, %, Integer) -> %
insert(x, u, i)returns a copy ofuhavingxas itsith element. Note:insert(x, u, i) = concat(u(minIndex(u)..i-1), concat(x, u(i..))).
- latex: % -> String if S has SetCategory
from SetCategory
- leftTrim: (%, S) -> % if % has finiteAggregate and S has BasicType
leftTrim(u, x)returns a copy ofuwith all leadingxdeleted. For example,leftTrim(" abc ", char " ")returns"abc ".
- less?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- map!: (S -> S, %) -> % if % has shallowlyMutable
from HomogeneousAggregate S
- map: ((S, S) -> S, %, %) -> %
map(f, u, v)returns a new aggregatewwith elementsz = f(x, y)for corresponding elementsxandyfromuandv. Note:w.i = f(u.i, v.i).- map: (S -> S, %) -> %
from HomogeneousAggregate S
- max: % -> S if % has finiteAggregate and S has OrderedSet
from HomogeneousAggregate S
- max: (%, %) -> % if % has finiteAggregate and S has OrderedSet
from OrderedSet
- max: ((S, S) -> Boolean, %) -> S if % has finiteAggregate
from HomogeneousAggregate S
- maxIndex: % -> Integer
from IndexedAggregate(Integer, S)
- member?: (S, %) -> Boolean if % has finiteAggregate and S has BasicType
from HomogeneousAggregate S
- members: % -> List S if % has finiteAggregate
from HomogeneousAggregate S
- merge: (%, %) -> % if % has finiteAggregate and S has OrderedSet
merge(u, v)mergesuandvin ascending order. Note:merge(u, v) = merge(<=, u, v).
- merge: ((S, S) -> Boolean, %, %) -> % if % has finiteAggregate
merge(p, a, b)returns an aggregatecwhich mergesaandb. The result is produced by examining each elementxofaandyofbsuccessively. Ifp(x, y)istrue, thenxis inserted into the result; otherwiseyis inserted. Ifxis chosen, the next element ofais examined, and so on. When all the elements of one aggregate are examined, the remaining elements of the other are appended. For example,merge(<, [1, 3], [2, 7, 5])returns[1, 2, 3, 7, 5].
- min: % -> S if % has finiteAggregate and S has OrderedSet
from HomogeneousAggregate S
- min: (%, %) -> % if % has finiteAggregate and S has OrderedSet
from OrderedSet
- minIndex: % -> Integer
from IndexedAggregate(Integer, S)
- more?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- new: (NonNegativeInteger, S) -> %
new(n, x)returns a new aggregate of sizenall of whose entries arex.
- parts: % -> List S if % has finiteAggregate
from HomogeneousAggregate S
- position: (S -> Boolean, %) -> Integer if % has finiteAggregate
position(p, a)returns the indexiof the firstxinasuch thatp(x)istrue, andminIndex(a) - 1if there is no suchx.
- position: (S, %) -> Integer if % has finiteAggregate and S has BasicType
position(x, a)returns the indexiof the first occurrence ofxin a, andminIndex(a) - 1if there is no suchx.
- position: (S, %, Integer) -> Integer if % has finiteAggregate and S has BasicType
position(x, a, n)returns the indexiof the first occurrence ofxinawherei >= n, andminIndex(a) - 1if no suchxis found.
- qelt: (%, Integer) -> S
from EltableAggregate(Integer, S)
- qsetelt!: (%, Integer, S) -> S if % has shallowlyMutable
from EltableAggregate(Integer, S)
- reduce: ((S, S) -> S, %) -> S if % has finiteAggregate
from Collection S
- reduce: ((S, S) -> S, %, S) -> S if % has finiteAggregate
from Collection S
- reduce: ((S, S) -> S, %, S, S) -> S if % has finiteAggregate and S has BasicType
from Collection S
- remove: (S -> Boolean, %) -> % if % has finiteAggregate
from Collection S
- remove: (S, %) -> % if % has finiteAggregate and S has BasicType
from Collection S
- removeDuplicates: % -> % if % has finiteAggregate and S has BasicType
from Collection S
- reverse!: % -> % if % has finiteAggregate and % has shallowlyMutable
reverse!(u)returnsuwith its elements in reverse order.
- reverse: % -> % if % has finiteAggregate
reverse(a)returns a copy ofawith elements in reverse order.
- rightTrim: (%, S) -> % if % has finiteAggregate and S has BasicType
rightTrim(u, x)returns a copy ofuwith all trailing occurrences ofxdeleted. For example,rightTrim(" abc ", char " ")returns" abc".
- select: (S -> Boolean, %) -> % if % has finiteAggregate
from Collection S
- setelt!: (%, Integer, S) -> S if % has shallowlyMutable
from EltableAggregate(Integer, S)
- setelt!: (%, UniversalSegment Integer, S) -> S if % has shallowlyMutable
setelt!(u, i..j, x)(also written:u(i..j) := x) destructively replaces each element in the segmentu(i..j)byx. The valuexis returned. Note:uis destructively changed so thatu.k := x for k in i..j; its length remains unchanged.
- size?: (%, NonNegativeInteger) -> Boolean
from Aggregate
- smaller?: (%, %) -> Boolean if % has finiteAggregate and S has Comparable or % has finiteAggregate and S has OrderedSet
from Comparable
- sort!: % -> % if % has finiteAggregate and S has OrderedSet and % has shallowlyMutable
sort!(u)returnsuwith its elements in ascending order.
- sort!: ((S, S) -> Boolean, %) -> % if % has finiteAggregate and % has shallowlyMutable
sort!(p, u)returnsuwith its elements ordered byp.
- sort: % -> % if % has finiteAggregate and S has OrderedSet
sort(u)returns anuwith elements in ascending order. Note:sort(u) = sort(<, u).
- sort: ((S, S) -> Boolean, %) -> % if % has finiteAggregate
sort(p, a)returns a copy ofasorted using total ordering predicatep.
- sorted?: % -> Boolean if % has finiteAggregate and S has OrderedSet
sorted?(u)tests if the elements ofuare in ascending order.
- sorted?: ((S, S) -> Boolean, %) -> Boolean if % has finiteAggregate
sorted?(p, a)tests ifais sorted according to predicatep.
- swap!: (%, Integer, Integer) -> Void if % has shallowlyMutable
from IndexedAggregate(Integer, S)
- trim: (%, S) -> % if % has finiteAggregate and S has BasicType
trim(u, x)returns a copy ofuwith all occurrences ofxdeleted from right and left ends. For example,trim(" abc ", char " ")returns"abc".
BasicType if % has finiteAggregate and S has BasicType or % has finiteAggregate and S has Hashable or S has SetCategory
CoercibleTo OutputForm if S has CoercibleTo OutputForm
Comparable if % has finiteAggregate and S has OrderedSet or % has finiteAggregate and S has Comparable
ConvertibleTo InputForm if S has ConvertibleTo InputForm
Eltable(UniversalSegment Integer, %)
Evalable S if S has SetCategory and S has Evalable S
Hashable if % has finiteAggregate and S has Hashable
InnerEvalable(S, S) if S has SetCategory and S has Evalable S
OrderedSet if % has finiteAggregate and S has OrderedSet
PartialOrder if % has finiteAggregate and S has OrderedSet
SetCategory if S has SetCategory