/usr/share/axiom-20170501/src/algebra/IBITS.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 | )abbrev domain IBITS IndexedBits
++ Author: Stephen Watt and Michael Monagan
++ Date Created: July 86
++ Change History: Oct 87
++ Description:
++ \spadtype{IndexedBits} is a domain to compactly represent
++ large quantities of Boolean data.
IndexedBits(mn) : SIG == CODE where
mn : Integer
SIG ==> BitAggregate() with
-- temporaries until parser gets better
Not : % -> %
++ Not(n) returns the bit-by-bit logical Not of n.
Or : (%, %) -> %
++ Or(n,m) returns the bit-by-bit logical Or of n and m.
And : (%, %) -> %
++ And(n,m) returns the bit-by-bit logical And of n and m.
CODE ==> add
range: (%, Integer) -> Integer
--++ range(j,i) returnes the range i of the boolean j.
minIndex u == mn
range(v, i) ==
i >= 0 and i < #v => i
error "Index out of range"
coerce(v):OutputForm ==
t:Character := char "1"
f:Character := char "0"
s := new(#v, space()$Character)$String
for i in minIndex(s)..maxIndex(s) for j in mn.. repeat
s.i := if v.j then t else f
s::OutputForm
new(n, b) == BVEC_-MAKE_-FULL(n,TRUTH_-TO_-BIT(b)$Lisp)$Lisp
empty() == BVEC_-MAKE_-FULL(0,0)$Lisp
copy v == BVEC_-COPY(v)$Lisp
#v == BVEC_-SIZE(v)$Lisp
v = u == BVEC_-EQUAL(v, u)$Lisp
v < u == BVEC_-GREATER(u, v)$Lisp
_and(u, v) == (#v=#u => BVEC_-AND(v,u)$Lisp; map("and",v,u))
_or(u, v) == (#v=#u => BVEC_-OR(v, u)$Lisp; map("or", v,u))
xor(v,u) == (#v=#u => BVEC_-XOR(v,u)$Lisp; map("xor",v,u))
setelt(v:%, i:Integer, f:Boolean) ==
BVEC_-SETELT(v, range(v, abs(i-mn)), TRUTH_-TO_-BIT(f)$Lisp)$Lisp
elt(v:%, i:Integer) ==
BIT_-TO_-TRUTH(BVEC_-ELT(v, range(v, abs(i-mn)))$Lisp)$Lisp
Not v == BVEC_-NOT(v)$Lisp
And(u, v) == (#v=#u => BVEC_-AND(v,u)$Lisp; map("and",v,u))
Or(u, v) == (#v=#u => BVEC_-OR(v, u)$Lisp; map("or", v,u))
|