LinearAggregate(S)

aggcat.spad line 1698 [edit on github]

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 S has OrderedSet and % has finiteAggregate
from PartialOrder
<= : (%, %) -> Boolean if S has OrderedSet and % has finiteAggregate
from PartialOrder
= : (%, %) -> Boolean if S has BasicType and % has finiteAggregate or S has Hashable and % has finiteAggregate or S has SetCategory
from BasicType
> : (%, %) -> Boolean if S has OrderedSet and % has finiteAggregate
from PartialOrder
>= : (%, %) -> Boolean if S has OrderedSet and % has finiteAggregate
from PartialOrder
any? : (Mapping(Boolean, S), %) -> 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 of u followed by the elements of v. Note: if w = concat(u, v) then w.i = u.i for i in indices u and w.(j + maxIndex u) = v.j for j in indices v.

concat : (%, S) -> %

concat(u, x) returns aggregate u with additional element x at the end. Note: for lists, concat(u, x) = concat(u, [x]).

concat : (S, %) -> %

concat(x, u) returns aggregate u with additional element x at the front. Note: for lists: concat(x, u) = concat([x], u).

concat : List(%) -> %

concat(u), where u is a list of aggregates [a, b, ..., c], returns a single aggregate consisting of the elements of a followed by those of b followed ... by the elements of c. 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)
copy : % -> %
from Aggregate
copyInto! : (%, %, Integer) -> % if % has finiteAggregate and % has shallowlyMutable

copyInto!(u, v, i) returns aggregate u containing a copy of v inserted at element i.

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

delete(u, i) returns a copy of u with the ith 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 of u with the ith through jth element deleted. Note: delete(u, i..j) = concat(u(minIndex(u)..i-1), u(j+1..)).

elt : (%, UniversalSegment(Integer)) -> %
from Eltable(UniversalSegment(Integer), %)
elt : (%, Integer) -> S
from Eltable(Integer, S)
elt : (%, Integer, S) -> S
from EltableAggregate(Integer, S)
empty : () -> %
from Aggregate
empty? : % -> Boolean
from Aggregate
entries : % -> List(S)
from IndexedAggregate(Integer, S)
entry? : (S, %) -> Boolean if S has BasicType and % has finiteAggregate
from IndexedAggregate(Integer, S)
eq? : (%, %) -> Boolean
from Aggregate
eval : (%, S, S) -> % if S has Evalable(S) and S has SetCategory
from InnerEvalable(S, S)
eval : (%, 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 : (%, List(Equation(S))) -> % if S has Evalable(S) and S has SetCategory
from Evalable(S)
every? : (Mapping(Boolean, S), %) -> Boolean if % has finiteAggregate
from HomogeneousAggregate(S)
fill! : (%, S) -> % if % has shallowlyMutable
from IndexedAggregate(Integer, S)
find : (Mapping(Boolean, S), %) -> Union(S, "failed")
from Collection(S)
first : (%, NonNegativeInteger) -> %

first(u, n) returns a copy of the first n elements of u. Error: if u has less than n elements.

first : % -> S
from IndexedAggregate(Integer, S)
hash : % -> SingleInteger if S has Hashable and % has finiteAggregate
from Hashable
hashUpdate! : (HashState, %) -> HashState if S has Hashable and % has finiteAggregate
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 of u having v inserted beginning at the ith 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 of u having x as its ith 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 S has BasicType and % has finiteAggregate

leftTrim(u, x) returns a copy of u with all leading x deleted. For example, leftTrim(" abc ", char " ") returns "abc ".

less? : (%, NonNegativeInteger) -> Boolean
from Aggregate
map : (Mapping(S, S), %) -> %
from HomogeneousAggregate(S)
map : (Mapping(S, S, S), %, %) -> %

map(f, u, v) returns a new aggregate w with elements z = f(x, y) for corresponding elements x and y from u and v. Note: w.i = f(u.i, v.i).

map! : (Mapping(S, S), %) -> % if % has shallowlyMutable
from HomogeneousAggregate(S)
max : (%, %) -> % if S has OrderedSet and % has finiteAggregate
from OrderedSet
max : % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate(S)
max : (Mapping(Boolean, S, S), %) -> S if % has finiteAggregate
from HomogeneousAggregate(S)
maxIndex : % -> Integer
from IndexedAggregate(Integer, S)
member? : (S, %) -> Boolean if S has BasicType and % has finiteAggregate
from HomogeneousAggregate(S)
members : % -> List(S) if % has finiteAggregate
from HomogeneousAggregate(S)
merge : (%, %) -> % if S has OrderedSet and % has finiteAggregate

merge(u, v) merges u and v in ascending order. Note: merge(u, v) = merge(<=, u, v).

merge : (Mapping(Boolean, S, S), %, %) -> % if % has finiteAggregate

merge(p, a, b) returns an aggregate c which merges a and b. The result is produced by examining each element x of a and y of b successively. If p(x, y) is true, then x is inserted into the result; otherwise y is inserted. If x is chosen, the next element of a is 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 : (%, %) -> % if S has OrderedSet and % has finiteAggregate
from OrderedSet
min : % -> S if S has OrderedSet and % has finiteAggregate
from HomogeneousAggregate(S)
minIndex : % -> Integer
from IndexedAggregate(Integer, S)
more? : (%, NonNegativeInteger) -> Boolean
from Aggregate
new : (NonNegativeInteger, S) -> %

new(n, x) returns a new aggregate of size n all of whose entries are x.

parts : % -> List(S) if % has finiteAggregate
from HomogeneousAggregate(S)
position : (S, %) -> Integer if S has BasicType and % has finiteAggregate

position(x, a) returns the index i of the first occurrence of x in a, and minIndex(a) - 1 if there is no such x.

position : (S, %, Integer) -> Integer if S has BasicType and % has finiteAggregate

position(x, a, n) returns the index i of the first occurrence of x in a where i >= n, and minIndex(a) - 1 if no such x is found.

position : (Mapping(Boolean, S), %) -> Integer if % has finiteAggregate

position(p, a) returns the index i of the first x in a such that p(x) is true, and minIndex(a) - 1 if there is no such x.

qelt : (%, Integer) -> S
from EltableAggregate(Integer, S)
qsetelt! : (%, Integer, S) -> S if % has shallowlyMutable
from EltableAggregate(Integer, S)
reduce : (Mapping(S, S, S), %) -> S if % has finiteAggregate
from Collection(S)
reduce : (Mapping(S, S, S), %, S) -> S if % has finiteAggregate
from Collection(S)
reduce : (Mapping(S, S, S), %, S, S) -> S if S has BasicType and % has finiteAggregate
from Collection(S)
remove : (S, %) -> % if S has BasicType and % has finiteAggregate
from Collection(S)
remove : (Mapping(Boolean, S), %) -> % if % has finiteAggregate
from Collection(S)
removeDuplicates : % -> % if S has BasicType and % has finiteAggregate
from Collection(S)
reverse : % -> % if % has finiteAggregate

reverse(a) returns a copy of a with elements in reverse order.

reverse! : % -> % if % has finiteAggregate and % has shallowlyMutable

reverse!(u) returns u with its elements in reverse order.

rightTrim : (%, S) -> % if S has BasicType and % has finiteAggregate

rightTrim(u, x) returns a copy of u with all trailing occurrences of x deleted. For example, rightTrim(" abc ", char " ") returns " abc".

sample : () -> %
from Aggregate
select : (Mapping(Boolean, S), %) -> % 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 segment u(i..j) by x. The value x is returned. Note: u is destructively changed so that u.k := x for k in i..j; its length remains unchanged.

size? : (%, NonNegativeInteger) -> Boolean
from Aggregate
smaller? : (%, %) -> Boolean if S has OrderedSet and % has finiteAggregate or % has finiteAggregate and S has Comparable
from Comparable
sort : % -> % if S has OrderedSet and % has finiteAggregate

sort(u) returns an u with elements in ascending order. Note: sort(u) = sort(<, u).

sort : (Mapping(Boolean, S, S), %) -> % if % has finiteAggregate

sort(p, a) returns a copy of a sorted using total ordering predicate p.

sort! : % -> % if S has OrderedSet and % has finiteAggregate and % has shallowlyMutable

sort!(u) returns u with its elements in ascending order.

sort! : (Mapping(Boolean, S, S), %) -> % if % has finiteAggregate and % has shallowlyMutable

sort!(p, u) returns u with its elements ordered by p.

sorted? : % -> Boolean if S has OrderedSet and % has finiteAggregate

sorted?(u) tests if the elements of u are in ascending order.

sorted? : (Mapping(Boolean, S, S), %) -> Boolean if % has finiteAggregate

sorted?(p, a) tests if a is sorted according to predicate p.

swap! : (%, Integer, Integer) -> Void if % has shallowlyMutable
from IndexedAggregate(Integer, S)
trim : (%, S) -> % if S has BasicType and % has finiteAggregate

trim(u, x) returns a copy of u with all occurrences of x deleted from right and left ends. For example, trim(" abc ", char " ") returns "abc".

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

Comparable

ConvertibleTo(InputForm)

Aggregate

Eltable(Integer, S)

IndexedAggregate(Integer, S)

InnerEvalable(S, S)

OrderedSet

SetCategory

HomogeneousAggregate(S)

Evalable(S)

PartialOrder

CoercibleTo(OutputForm)

Collection(S)

Eltable(UniversalSegment(Integer), %)

EltableAggregate(Integer, S)

Hashable

BasicType