/usr/share/axiom-20170501/src/algebra/SEG.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 | )abbrev domain SEG Segment
++ Author: Stephen M. Watt
++ Date Created: December 1986
++ Date Last Updated: June 3, 1991
++ Description:
++ This type is used to specify a range of values from type \spad{S}.
Segment(S) : SIG == CODE where
S : Type
SIG ==> SegmentCategory(S) with
if S has SetCategory then SetCategory
if S has OrderedRing then SegmentExpansionCategory(S, List S)
CODE ==> add
Rep := Record(low: S, high: S, incr: Integer)
a..b == [a,b,1]
lo s == s.low
low s == s.low
hi s == s.high
high s == s.high
incr s == s.incr
segment(a,b) == [a,b,1]
BY(s, r) == [lo s, hi s, r]
if S has SetCategory then
(s1:%) = (s2:%) ==
s1.low = s2.low and s1.high=s2.high and s1.incr = s2.incr
coerce(s:%):OutputForm ==
seg := SEGMENT(s.low::OutputForm, s.high::OutputForm)
s.incr = 1 => seg
infix(" by "::OutputForm, seg, s.incr::OutputForm)
convert a == [a,a,1]
if S has OrderedRing then
expand(ls: List %):List S ==
lr := nil()$List(S)
for s in ls repeat
l := lo s
h := hi s
inc := (incr s)::S
zero? inc => error "Cannot expand a segment with an increment of zero"
if inc > 0 then
while l <= h repeat
lr := concat(l, lr)
l := l + inc
else
while l >= h repeat
lr := concat(l, lr)
l := l + inc
reverse_! lr
expand(s : %) == expand([s]$List(%))$%
map(f : S->S, s : %): List S ==
lr := nil()$List(S)
l := lo s
h := hi s
inc := (incr s)::S
if inc > 0 then
while l <= h repeat
lr := concat(f l, lr)
l := l + inc
else
while l >= h repeat
lr := concat(f l, lr)
l := l + inc
reverse_! lr
|