aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/collection/sequence.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/data/collection/sequence.lux')
-rw-r--r--stdlib/source/library/lux/data/collection/sequence.lux18
1 files changed, 6 insertions, 12 deletions
diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux
index d60fd99d4..a7d2cc0b4 100644
--- a/stdlib/source/library/lux/data/collection/sequence.lux
+++ b/stdlib/source/library/lux/data/collection/sequence.lux
@@ -23,11 +23,12 @@
{#.doc "An infinite sequence of values."}
(Cont [a (Sequence a)]))
-(def: .public (iterations f x)
- {#.doc "Create a sequence by applying a function to a value, and to its result, on and on..."}
- (All [a]
- (-> (-> a a) a (Sequence a)))
- (//.pending [x (iterations f (f x))]))
+(def: .public (iterations step init)
+ {#.doc "A stateful way of infinitely calculating the values of a sequence."}
+ (All [a b]
+ (-> (-> a [a b]) a (Sequence b)))
+ (let [[next x] (step init)]
+ (//.pending [x (iterations step next)])))
(def: .public (repeated x)
{#.doc "Repeat a value forever."}
@@ -101,13 +102,6 @@
[split_at Nat (n.= 0 pred) (dec pred)]
)
-(def: .public (unfold step init)
- {#.doc "A stateful way of infinitely calculating the values of a sequence."}
- (All [a b]
- (-> (-> a [a b]) a (Sequence b)))
- (let [[next x] (step init)]
- (//.pending [x (unfold step next)])))
-
(def: .public (only predicate sequence)
{#.doc (example "A new sequence only with items that satisfy the predicate.")}
(All [a] (-> (-> a Bit) (Sequence a) (Sequence a)))