/usr/share/axiom-20170501/src/algebra/LNAGG.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | )abbrev category LNAGG LinearAggregate
++ Author: Michael Monagan; revised by Manuel Bronstein and Richard Jenks
++ Date Created: August 87 through August 88
++ Date Last Updated: April 1991
++ Description:
++ 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, \spadfun{concat} of two lists needs only to copy its first
++ argument, whereas \spadfun{concat} of two arrays needs to copy both
++ arguments. Most of the operations exported here apply to infinite
++ objects (for example, streams) as well to finite ones.
++ For finite linear aggregates, see \spadtype{FiniteLinearAggregate}.
LinearAggregate(S) : Category == SIG where
S : Type
IA ==> IndexedAggregate(Integer,S)
CO ==> Collection(S)
SIG ==> Join(IA,CO) with
new : (NonNegativeInteger,S) -> %
++ new(n,x) returns \axiom{fill!(new n,x)}.
concat : (%,S) -> %
++ concat(u,x) returns aggregate u with additional element x at the end.
++ Note that for lists, \axiom{concat(u,x) == concat(u,[x])}
concat : (S,%) -> %
++ concat(x,u) returns aggregate u with additional element at the front.
++ Note that for lists: \axiom{concat(x,u) == concat([x],u)}.
concat : (%,%) -> %
++ concat(u,v) returns an aggregate consisting of the elements of u
++ followed by the elements of v.
++ Note that if \axiom{w = concat(u,v)} then
++ \axiom{w.i = u.i for i in indices u}
++ and \axiom{w.(j + maxIndex u) = v.j for j in indices v}.
concat : List % -> %
++ concat(u), where u is a lists of aggregates \axiom{[a,b,...,c]},
++ returns a single aggregate consisting of the elements of \axiom{a}
++ followed by those
++ of b followed ... by the elements of c.
++ Note that \axiom{concat(a,b,...,c) = concat(a,concat(b,...,c))}.
map : ((S,S)->S,%,%) -> %
++ map(f,u,v) returns a new collection w with elements
++ \axiom{z = f(x,y)} for corresponding elements x and y from u and v.
++ Note that for linear aggregates, \axiom{w.i = f(u.i,v.i)}.
elt : (%,UniversalSegment(Integer)) -> %
++ elt(u,i..j) (also written: \axiom{a(i..j)}) returns the aggregate of
++ elements \axiom{u} for k from i to j in that order.
++ Note that in general, \axiom{a.s = [a.k for i in s]}.
delete : (%,Integer) -> %
++ delete(u,i) returns a copy of u with the \axiom{i}th
++ element deleted. Note that for lists,
++ \axiom{delete(a,i) == concat(a(0..i - 1),a(i + 1,..))}.
delete : (%,UniversalSegment(Integer)) -> %
++ delete(u,i..j) returns a copy of u with the \axiom{i}th through
++ \axiom{j}th element deleted.
++ Note that \axiom{delete(a,i..j) = concat(a(0..i-1),a(j+1..))}.
insert : (S,%,Integer) -> %
++ insert(x,u,i) returns a copy of u having x as its
++ \axiom{i}th element.
++ Note that \axiom{insert(x,a,k) = concat(concat(a(0..k-1),x),a(k..))}.
insert : (%,%,Integer) -> %
++ insert(v,u,k) returns a copy of u having v inserted beginning at the
++ \axiom{i}th element.
++ Note that \axiom{insert(v,u,k) = concat( u(0..k-1), v, u(k..) )}.
if % has shallowlyMutable then
setelt : (%,UniversalSegment(Integer),S) -> S
++ setelt(u,i..j,x) (also written: \axiom{u(i..j) := x}) destructively
++ replaces each element in the segment \axiom{u(i..j)} by x.
++ The value x is returned.
++ Note that u is destructively change so
++ that \axiom{u.k := x for k in i..j};
++ its length remains unchanged.
add
indices a == [i for i in minIndex a .. maxIndex a]
index?(i, a) == i >= minIndex a and i <= maxIndex a
concat(a:%, x:S) == concat(a, new(1, x))
concat(x:S, y:%) == concat(new(1, x), y)
insert(x:S, a:%, i:Integer) == insert(new(1, x), a, i)
if % has finiteAggregate then
maxIndex l == #l - 1 + minIndex l
|