/usr/share/axiom-20170501/src/algebra/CSTTOOLS.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 | )abbrev package CSTTOOLS CyclicStreamTools
++ Author: Clifton J. Williamson
++ Date Created: 5 December 1989
++ Date Last Updated: 5 December 1989
++ Description:
++ This package provides tools for working with cyclic streams.
CyclicStreamTools(S,ST) : SIG == CODE where
S : Type
ST : LazyStreamAggregate S
SIG ==> with
cycleElt : ST -> Union(ST,"failed")
++ cycleElt(s) returns a pointer to a node in the cycle if the stream
++ s is cyclic and returns "failed" if s is not cyclic
++
++X p:=repeating([1,2,3])
++X q:=cons(4,p)
++X cycleElt q
++X r:=[1,2,3]::Stream(Integer)
++X cycleElt r
computeCycleLength : ST -> NonNegativeInteger
++ computeCycleLength(s) returns the length of the cycle of a
++ cyclic stream t, where s is a pointer to a node in the
++ cyclic part of t.
++
++X p:=repeating([1,2,3])
++X q:=cons(4,p)
++X computeCycleLength(cycleElt(q))
computeCycleEntry : (ST,ST) -> ST
++ computeCycleEntry(x,cycElt), where cycElt is a pointer to a
++ node in the cyclic part of the cyclic stream x, returns a
++ pointer to the first node in the cycle
++
++X p:=repeating([1,2,3])
++X q:=cons(4,p)
++X computeCycleEntry(q,cycleElt(q))
CODE ==> add
cycleElt x ==
y := x
for i in 0.. repeat
(explicitlyEmpty? y) or (lazy? y) => return "failed"
y := rst y
if odd? i then x := rst x
eq?(x,y) => return y
computeCycleLength cycElt ==
i : NonNegativeInteger
y := cycElt
for i in 1.. repeat
y := rst y
eq?(y,cycElt) => return i
computeCycleEntry(x,cycElt) ==
y := rest(x, computeCycleLength cycElt)
repeat
eq?(x,y) => return x
x := rst x ; y := rst y
|