/usr/share/axiom-20170501/src/algebra/TUPLE.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 | )abbrev domain TUPLE Tuple
++ Author: Mark Botch
++ Description:
++ This domain is used to interface with the interpreter's notion
++ of comma-delimited sequences of values.
Tuple(S) : SIG == CODE where
S : Type
SIG ==> CoercibleTo(PrimitiveArray S) with
coerce : PrimitiveArray S -> %
++ coerce(a) makes a tuple from primitive array a
++
++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
++X t2:=coerce(t1)$Tuple(Integer)
select : (%, NonNegativeInteger) -> S
++ select(x,n) returns the n-th element of tuple x.
++ tuples are 0-based
++
++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
++X t2:=coerce(t1)$Tuple(Integer)
++X select(t2,3)
length : % -> NonNegativeInteger
++ length(x) returns the number of elements in tuple x
++
++X t1:PrimitiveArray(Integer):= [i for i in 1..10]
++X t2:=coerce(t1)$Tuple(Integer)
++X length(t2)
if S has SetCategory then SetCategory
CODE ==> add
Rep := Record(len : NonNegativeInteger, elts : PrimitiveArray S)
coerce(x: PrimitiveArray S): % == [#x, x]
coerce(x:%): PrimitiveArray(S) == x.elts
length x == x.len
select(x, n) ==
n >= x.len => error "Index out of bounds"
x.elts.n
if S has SetCategory then
x = y == (x.len = y.len) and (x.elts =$PrimitiveArray(S) y.elts)
coerce(x : %): OutputForm ==
paren [(x.elts.i)::OutputForm
for i in minIndex x.elts .. maxIndex x.elts]$List(OutputForm)
|