Skip to content

Commit b3d4116

Browse files
author
angusiguess
committed
Add sequence to stdlib
1 parent 9c900fc commit b3d4116

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pixie/stdlib.pxi

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ If further arguments are passed, invokes the method named by symbol, passing the
903903
(if (next coll)
904904
(recur (next coll))
905905
(first coll))
906-
906+
907907
(satisfies? ISeqable coll)
908908
(recur (seq coll))))
909909

@@ -2106,7 +2106,7 @@ For more information, see http://clojure.org/special_forms#binding-forms"}
21062106
val
21072107
not-found)))
21082108
ISeq
2109-
(-first [this]
2109+
(-first [this]
21102110
(when (not= start stop)
21112111
start))
21122112
(-next [this]
@@ -2188,6 +2188,14 @@ For more information, see http://clojure.org/special_forms#binding-forms"}
21882188
([pred coll]
21892189
(filter (complement pred) coll)))
21902190

2191+
(defn sequence
2192+
"Returns a lazy sequence of `data`, optionally transforming it using `xform`.
2193+
Given an `eduction`, produces a lazy sequence of it."
2194+
([eduction]
2195+
(lazy-seq (cons (first eduction) (sequence (rest eduction)))))
2196+
([xform data]
2197+
(sequence (eduction xform data))))
2198+
21912199
(defn distinct
21922200
{:doc "Returns the distinct elements in the collection."
21932201
:signatures [[] [coll]]
@@ -3080,7 +3088,7 @@ ex: (vary-meta x assoc :foo 42)"
30803088
(deftype Iterate [f x]
30813089
IReduce
30823090
(-reduce [self rf init]
3083-
(loop [next (f x)
3091+
(loop [next (f x)
30843092
acc (rf init x)]
30853093
(if (reduced? acc)
30863094
@acc

0 commit comments

Comments
 (0)