Skip to content

Commit 36ce07e

Browse files
Merge pull request #500 from thomasmulvaney/iterate-reduce-speed
fixes the speed of iterates reduce
2 parents d24b17a + 3f81e65 commit 36ce07e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pixie/stdlib.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,11 +3080,11 @@ ex: (vary-meta x assoc :foo 42)"
30803080
(deftype Iterate [f x]
30813081
IReduce
30823082
(-reduce [self rf init]
3083-
(loop [col (rest self)
3084-
acc (rf init (first self))]
3083+
(loop [next (f x)
3084+
acc (rf init x)]
30853085
(if (reduced? acc)
30863086
@acc
3087-
(recur (rest col) (rf acc (first col))))))
3087+
(recur (f next) (rf acc next)))))
30883088
ISeq
30893089
(-seq [self]
30903090
(cons x (lazy-seq* (fn [] (->Iterate f (f x)))))))

0 commit comments

Comments
 (0)