Fix dedupe: make-lazy-seq + coll->cells for 20-coll tier
The lazy-seq macro (30-macros.clj) is not available when 20-coll loads. Use explicit (make-lazy-seq (fn* [] (coll->cells ...))) expansion. Also fix outer cons leaking raw @[val thunk] cell. 22/22 lazy-infinite, conformance 229 interpret + self-host.
This commit is contained in:
parent
0782bf3e48
commit
a414402109
1 changed files with 11 additions and 8 deletions
|
|
@ -223,16 +223,19 @@
|
||||||
;; Eager dedupe of consecutive equal elements (Jolt has no transducer arity yet).
|
;; Eager dedupe of consecutive equal elements (Jolt has no transducer arity yet).
|
||||||
(defn dedupe [coll]
|
(defn dedupe [coll]
|
||||||
(let [step (fn step [s prev]
|
(let [step (fn step [s prev]
|
||||||
(lazy-seq
|
(make-lazy-seq
|
||||||
(let [s (seq s)]
|
(fn* []
|
||||||
(when s
|
(let [s (seq s)]
|
||||||
(let [x (first s)]
|
(if s
|
||||||
(if (= x prev)
|
(let [x (first s)]
|
||||||
(step (rest s) prev)
|
(if (= x prev)
|
||||||
(cons x (step (rest s) x))))))))]
|
(coll->cells (step (rest s) prev))
|
||||||
|
(coll->cells (cons x (step (rest s) x)))))
|
||||||
|
nil)))))]
|
||||||
(let [s (seq coll)]
|
(let [s (seq coll)]
|
||||||
(if s
|
(if s
|
||||||
(cons (first s) (step (rest s) (first s)))
|
(make-lazy-seq
|
||||||
|
(fn* [] (coll->cells (cons (first s) (step (rest s) (first s))))))
|
||||||
()))))
|
()))))
|
||||||
|
|
||||||
;; Internal helper for {:keys [...]} destructuring over a seq of k/v pairs:
|
;; Internal helper for {:keys [...]} destructuring over a seq of k/v pairs:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue