/usr/share/axiom-20170501/src/algebra/IARRAY1.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 | )abbrev domain IARRAY1 IndexedOneDimensionalArray
++ Author Micheal Monagan Aug/87
++ Description:
++ This is the basic one dimensional array data type.
IndexedOneDimensionalArray(S,mn) : SIG == CODE where
S : Type
mn : Integer
SIG ==> OneDimensionalArrayAggregate S
CODE ==> add
Qmax ==> QVMAXINDEX$Lisp
Qsize ==> QVSIZE$Lisp
Qelt ==> ELT$Lisp
Qsetelt ==> SETELT$Lisp
Qnew ==> MAKE_-ARRAY$Lisp
I ==> Integer
#x == Qsize x
fill_!(x, s) == (for i in 0..Qmax x repeat Qsetelt(x, i, s); x)
minIndex x == mn
empty() == Qnew(0$Lisp)
new(n, s) == fill_!(Qnew n,s)
map_!(f, s1) ==
n:Integer := Qmax(s1)
n < 0 => s1
for i in 0..n repeat Qsetelt(s1, i, f(Qelt(s1,i)))
s1
map(f, s1) ==
n:Integer := Qmax(s1)
n < 0 => s1
ss2:% := Qnew(n+1)
for i in 0..n repeat Qsetelt(ss2, i, f(Qelt(s1,i)))
ss2
map(f, a, b) ==
maxind:Integer := min(Qmax a, Qmax b)
maxind < 0 => empty()
c:% := Qnew(maxind+1)
for i in 0..maxind repeat
Qsetelt(c, i, f(Qelt(a,i),Qelt(b,i)))
c
if zero? mn then
qelt(x, i) == Qelt(x, i)
qsetelt_!(x, i, s) == Qsetelt(x, i, s)
elt(x:%, i:I) ==
negative? i or i > maxIndex(x) => error "index out of range"
qelt(x, i)
setelt(x:%, i:I, s:S) ==
negative? i or i > maxIndex(x) => error "index out of range"
qsetelt_!(x, i, s)
else if (mn = 1) then
maxIndex x == Qsize x
qelt(x, i) == Qelt(x, i-1)
qsetelt_!(x, i, s) == Qsetelt(x, i-1, s)
elt(x:%, i:I) ==
QSLESSP(i,1$Lisp)$Lisp or QSLESSP(Qsize x,i)$Lisp =>
error "index out of range"
Qelt(x, i-1)
setelt(x:%, i:I, s:S) ==
QSLESSP(i,1$Lisp)$Lisp or QSLESSP(Qsize x,i)$Lisp =>
error "index out of range"
Qsetelt(x, i-1, s)
else
qelt(x, i) == Qelt(x, i - mn)
qsetelt_!(x, i, s) == Qsetelt(x, i - mn, s)
elt(x:%, i:I) ==
i < mn or i > maxIndex(x) => error "index out of range"
qelt(x, i)
setelt(x:%, i:I, s:S) ==
i < mn or i > maxIndex(x) => error "index out of range"
qsetelt_!(x, i, s)
|