/usr/share/axiom-20170501/src/algebra/SEXOF.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 | )abbrev domain SEXOF SExpressionOf
++ Author: S.M.Watt
++ Date Created: July 1987
++ Date Last Modified: 23 May 1991
++ Description:
++ This domain allows the manipulation of Lisp values over
++ arbitrary atomic types.
-- Allows the names of the atomic types to be chosen.
-- *** Warning *** Although the parameters are declared only to be Sets,
-- *** Warning *** they must have the appropriate representations.
SExpressionOf(Str, Sym, Int, Flt, Expr) : SIG == CODE where
Str : SetCategory
Sym : SetCategory
Int : SetCategory
Flt : SetCategory
Expr : SetCategory
SIG ==> SExpressionCategory(Str, Sym, Int, Flt, Expr)
CODE ==> add
Rep := Expr
dotex:OutputForm := INTERN(".")$Lisp
coerce(b:%):OutputForm ==
null? b => paren empty()
atom? b => coerce(b)$Rep
r := b
while not atom? r repeat r := cdr r
l1 := [b1::OutputForm for b1 in (l := destruct b)]
not null? r =>
paren blankSeparate concat_!(l1, [dotex, r::OutputForm])
#l = 2 and (first(l1) = QUOTE)@Boolean => quote first rest l1
paren blankSeparate l1
b1 = b2 == EQUAL(b1,b2)$Lisp
eq(b1, b2) == EQ(b1,b2)$Lisp
null? b == NULL(b)$Lisp
atom? b == ATOM(b)$Lisp
pair? b == CONSP(b)$Lisp
list? b == CONSP(b)$Lisp or NULL(b)$Lisp
string? b == STRINGP(b)$Lisp
symbol? b == IDENTP(b)$Lisp
integer? b == INTEGERP(b)$Lisp
float? b == FLOATP(b)$Lisp
destruct b == (list? b => b pretend List %; error "Non-list")
string b == (STRINGP(b)$Lisp=> b pretend Str;error "Non-string")
symbol b == (IDENTP(b)$Lisp => b pretend Sym;error "Non-symbol")
float b == (FLOATP(b)$Lisp => b pretend Flt;error "Non-float")
integer b == (INTEGERP(b)$Lisp => b pretend Int;error "Non-integer")
expr b == b pretend Expr
convert(l: List %) == l pretend %
convert(st: Str) == st pretend %
convert(sy: Sym) == sy pretend %
convert(n: Int) == n pretend %
convert(f: Flt) == f pretend %
convert(e: Expr) == e
car b == CAR(b)$Lisp
cdr b == CDR(b)$Lisp
# b == LENGTH(b)$Lisp
elt(b:%, i:Integer) == destruct(b).i
elt(b:%, li:List Integer) ==
for i in li repeat b := destruct(b).i
b
|