1. partition+concat removed from 10-seq.clj overlay — they use lazy-seq macro which produces raw make-lazy-seq forms in compile mode (same issue as mapcat overlay reversal). Must stay native. 2. Dead defns removed from core.janet: core-map-indexed, core-iterate, core-repeatedly (30 lines). Bindings already removed in prior commit. 3. dedupe removed from 40-lazy.clj — belongs in 20-coll.clj. Gates: conformance 229×3, lazy-infinite 22/22, specs 32/32.
36 lines
No EOL
1.5 KiB
Clojure
36 lines
No EOL
1.5 KiB
Clojure
;; clojure.core — seq tier. Pure-Clojure leaf sequence fns on top of the kernel
|
|
;; tier (00-kernel) and the Janet seed. Loaded after the kernel tier; in compile
|
|
;; mode these self-host through the now-built analyzer (interpreted otherwise).
|
|
;;
|
|
;; Migration rule for adding fns here: the fn must (1) NOT be in
|
|
;; compiler/core-renames (that map emits core-X Janet symbols directly), (2) have
|
|
;; no internal Janet callers of its core-X binding, and (3) NOT be used by the
|
|
;; self-hosted compiler (jolt-core/jolt/*.clj). Compiler-facing structural fns go
|
|
;; in the kernel tier (00-kernel) instead — see its header.
|
|
|
|
(defn ffirst [coll] (first (first coll)))
|
|
(defn nfirst [coll] (next (first coll)))
|
|
(defn fnext [coll] (first (next coll)))
|
|
(defn nnext [coll] (next (next coll)))
|
|
|
|
;; Canonical Clojure defs: pure first/next/loop/recur, no Janet realize-for-iteration.
|
|
(defn last [s]
|
|
(if (next s) (recur (next s)) (first s)))
|
|
|
|
(defn butlast [s]
|
|
(loop [ret [] s s]
|
|
(if (next s)
|
|
(recur (conj ret (first s)) (next s))
|
|
(seq ret))))
|
|
|
|
;; Lazy partition-by: groups consecutive elements by (f x), matching Clojure/CLJS.
|
|
(defn partition-by [f coll]
|
|
(let [step (fn step [s]
|
|
(lazy-seq
|
|
(let [s (seq s)]
|
|
(when s
|
|
(let [fst (first s)
|
|
fv (f fst)
|
|
run (cons fst (take-while (fn [x] (= fv (f x))) (rest s)))]
|
|
(cons run (step (lazy-seq (drop (count run) s)))))))))]
|
|
(step coll))) |