core: Phase 5 Option A — remaining lazy transformers + nth falsy-element fix
Converts the rest of the lazy transformers to return a LazySeq even over a concrete collection (dropping the eager "preserve representation" branch, which returned a vector over vector input): drop, distinct, partition, partition-all, map-indexed, keep, keep-indexed, take-nth, interpose. Each collapses to its existing lazy branch run over (lazy-from coll); transducer arities unchanged. Fixes a latent nth bug exposed by this: core-nth's lazy branch walked with (ls-first cur) truthiness as the end-of-seq test, so a legitimate false/nil element was mistaken for the end — (nth (map identity [false 1 2]) 0) threw instead of returning false, and cond-> (whose macro nths over a now-lazy (drop 2 clauses) containing the boolean clause tests) failed. nth now walks with seq-done? and reads via core-first. Gate: conformance 246x3 (+7 cases), lazy-infinite 18/18, fixpoint, self-host, all specs+unit green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
074eb2da41
commit
fa36488dad
2 changed files with 116 additions and 158 deletions
|
|
@ -76,6 +76,15 @@
|
|||
["juxt fns in vec" "[1 3]" "((juxt first last) [1 2 3])"]
|
||||
["last of lazy take" "5" "(last (take 5 (iterate inc 1)))"]
|
||||
["next empty lazy" "nil" "(next (take 1 [1]))"]
|
||||
# drop/distinct/partition/map-indexed/take-nth/interpose/keep are lazy too
|
||||
["drop vec is seq" "true" "(seq? (drop 1 [1 2 3]))"]
|
||||
["distinct vec is seq" "true" "(seq? (distinct [1 1 2]))"]
|
||||
["map-indexed is seq" "true" "(seq? (map-indexed vector [1 2]))"]
|
||||
["partition vec lazy" "(quote ((1 2) (3 4)))" "(partition 2 [1 2 3 4 5])"]
|
||||
# nth over a lazy seq must not treat a false/nil element as end-of-seq
|
||||
["nth lazy false elem" "false" "(nth (map identity [false 1 2]) 0)"]
|
||||
["nth lazy past false" "2" "(nth (drop 1 (list false 1 2)) 1)"]
|
||||
["cond-> false clause" "2" "(cond-> 1 true inc false inc)"]
|
||||
|
||||
### ---- HIGH: destructuring ----
|
||||
["destr nested seq" "[1 2 3]" "(let [[a [b c]] [1 [2 3]]] [a b c])"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue