aboutsummaryrefslogtreecommitdiff
path: root/src/algebra
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-19 17:44:50 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-19 17:44:50 +0000
commitcc69cdefa3acf48bad75ac52f55cd9f27c970eab (patch)
tree2e86afab7e70d80c194cd70fc1c9e9525cf2c062 /src/algebra
parent1da04848e6612031bc25a3f238c37c47204c9e93 (diff)
downloadopen-axiom-cc69cdefa3acf48bad75ac52f55cd9f27c970eab.tar.gz
* algebra/aggcat.spad.pamphlet (Aggregate) [#]: Remove export.
(UnaryRecursiveAggregate): Make definiton conditional. * algebra/stream.spad.pamphlet (LazyStreamAggregate): Likewise.
Diffstat (limited to 'src/algebra')
-rw-r--r--src/algebra/aggcat.spad.pamphlet17
-rw-r--r--src/algebra/stream.spad.pamphlet20
2 files changed, 19 insertions, 18 deletions
diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet
index b0395fe0..79973f91 100644
--- a/src/algebra/aggcat.spad.pamphlet
+++ b/src/algebra/aggcat.spad.pamphlet
@@ -49,8 +49,6 @@ Aggregate: Category == Type with
empty?: % -> Boolean
++ empty?(u) tests if u has 0 elements.
sample: constant -> % ++ sample yields a value of type %
- if % has finiteAggregate then
- #: % -> NonNegativeInteger ++ # u returns the number of items in u.
add
eq?(a,b) == %peq(a,b)$Foreign(Builtin)
sample() == empty()
@@ -1593,13 +1591,14 @@ UnaryRecursiveAggregate(S:Type): Category == RecursiveAggregate S with
empty? x => error "value of empty object"
first x
- #x ==
- k: NonNegativeInteger := 0
- while not empty? x repeat
- k = cycleMax and cyclic? x => error "cyclic list"
- x := rest x
- k := k + 1
- k
+ if % has FiniteAggregate S then
+ #x ==
+ k: NonNegativeInteger := 0
+ while not empty? x repeat
+ k = cycleMax and cyclic? x => error "cyclic list"
+ x := rest x
+ k := k + 1
+ k
tail x ==
empty? x => error "empty list"
diff --git a/src/algebra/stream.spad.pamphlet b/src/algebra/stream.spad.pamphlet
index 90fd504c..7b2db025 100644
--- a/src/algebra/stream.spad.pamphlet
+++ b/src/algebra/stream.spad.pamphlet
@@ -122,15 +122,17 @@ LazyStreamAggregate(S:Type): Category == StreamAggregate(S) with
empty? x => n = 0
size?(rst x,(n-1) :: NNI)
- # x ==
- -- error if stream is not finite
- y := x
- for i in 0.. repeat
- explicitlyEmpty? y => return i
- lazy? y => error "#: infinite stream"
- y := rst y
- if odd? i then x := rst x
- eq?(x,y) => error "#: infinite stream"
+--% FINAGG functions
+ if % has FiniteAggregate S then
+ # x ==
+ -- error if stream is not finite
+ y := x
+ for i in 0.. repeat
+ explicitlyEmpty? y => return i
+ lazy? y => error "#: infinite stream"
+ y := rst y
+ if odd? i then x := rst x
+ eq?(x,y) => error "#: infinite stream"
--% CLAGG functions