Step 5: partition-by, dedupe → lazy overlay + trampoline/rand-int overlay
partition-by (10-seq.clj): ported canonical lazy implementation from CLJS — lazy-seq + cons + take-while, matching Clojure/CLJS exactly. Fixes the third and final remaining leak from Step 3. dedupe (20-coll.clj): replaced eager vec-based impl with lazy step function using lazy-seq + cons. Infinite input no longer hangs. trampoline (20-coll.clj): pure HOF ported from CLJS — recur until non-function result. Removed core-trampoline + binding from Janet. rand-int (20-coll.clj): thin overlay over Janet math/random + math/floor. Removed core-rand-int + binding from Janet. Removed core-partition-by + binding from core.janet (now in overlay). Tests: added dedupe infinite-input case to lazy-infinite harness. 22/22 pass. Conformance 229x3. Specs 32/32.
This commit is contained in:
parent
42da5cef9a
commit
64b1c60939
4 changed files with 37 additions and 31 deletions
|
|
@ -55,6 +55,7 @@
|
|||
["take 6 mapcat dup range" "(quote (0 0 1 1 2 2))" "(take 6 (mapcat (fn [x] [x x]) (range)))"]
|
||||
["first rest lazy" "1" "(let [[a & r] (range)] (first r))"]
|
||||
["take 3 rest lazy" "(quote (1 2 3))" "(let [[a & r] (range)] (take 3 r))"]
|
||||
["dedupe inf" "(quote (1 2 1 2 1))" "(take 5 (dedupe (cycle [1 1 2 2])))"]
|
||||
["take 3 take-nth 2 range" "(quote (0 2 4))" "(take 3 (take-nth 2 (range)))"]
|
||||
["take 3 interpose :x range" "(quote (0 :x 1))" "(take 3 (interpose :x (range)))"]
|
||||
["take 3 map vector range iterate" "(quote ([0 100] [1 101] [2 102]))" "(take 3 (map vector (range) (iterate inc 100)))"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue