From 681b007b7a303c7c384571265c2a2c5e7c235710 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 6 Jun 2026 23:05:24 -0400 Subject: [PATCH] core: move split-at/split-with/ident?/qualified-ident?/simple-ident? to overlay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Second pure-fn batch (jolt-1j0 phase 2). All leaf fns; canonical Clojure defs. split-with now returns seqs for the parts (drop-while is a seq), matching Clojure rather than the prior all-vector result — value-equal either way. conformance 218/218 x3, clojure-test-suite 3927, core-bench 2333ms (~baseline). --- jolt-core/clojure/core/20-coll.clj | 10 ++++++++++ src/jolt/core.janet | 20 -------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/jolt-core/clojure/core/20-coll.clj b/jolt-core/clojure/core/20-coll.clj index fea2882..34d5f7c 100644 --- a/jolt-core/clojure/core/20-coll.clj +++ b/jolt-core/clojure/core/20-coll.clj @@ -65,3 +65,13 @@ (defn not-any? [pred coll] (not (some pred coll))) (defn not-every? [pred coll] (not (every? pred coll))) + +(defn split-at [n coll] [(take n coll) (drop n coll)]) + +(defn split-with [pred coll] [(take-while pred coll) (drop-while pred coll)]) + +(defn ident? [x] (or (keyword? x) (symbol? x))) + +(defn qualified-ident? [x] (or (qualified-symbol? x) (qualified-keyword? x))) + +(defn simple-ident? [x] (or (simple-symbol? x) (simple-keyword? x))) diff --git a/src/jolt/core.janet b/src/jolt/core.janet index 1bc029b..1e532c7 100644 --- a/src/jolt/core.janet +++ b/src/jolt/core.janet @@ -1408,11 +1408,6 @@ (and (keyword? x) (not (nil? (string/find "/" (string x)))))) (defn core-simple-keyword? [x] (and (keyword? x) (nil? (string/find "/" (string x))))) -(defn core-ident? [x] (or (core-keyword? x) (core-symbol? x))) -(defn core-qualified-ident? [x] - (or (core-qualified-symbol? x) (core-qualified-keyword? x))) -(defn core-simple-ident? [x] - (or (core-simple-symbol? x) (core-simple-keyword? x))) # Jolt has no inst/uri/uuid host types, so these are always false; inst-ms has # nothing valid to read. (defn core-inst? [x] false) @@ -3076,16 +3071,6 @@ {:jolt/type :symbol :ns ns :name nm}) (error "symbol expects 1 or 2 args"))) -(defn core-split-at [n coll] - (let [c (realize-for-iteration coll) m (min n (length c))] - [(tuple/slice (tuple ;(array/slice c 0 m))) (tuple/slice (tuple ;(array/slice c m)))])) - -(defn core-split-with [pred coll] - (let [c (realize-for-iteration coll)] - (var i 0) - (while (and (< i (length c)) (truthy? (pred (in c i)))) (++ i)) - [(tuple/slice (tuple ;(array/slice c 0 i))) (tuple/slice (tuple ;(array/slice c i)))])) - (defn- td-take-nth [n] (fn [rf] (var i 0) @@ -3785,8 +3770,6 @@ "sorted?" core-sorted-map? "reduced" core-reduced "reduced?" core-reduced? - "split-at" core-split-at - "split-with" core-split-with "take-nth" core-take-nth "nthrest" core-nthrest "nthnext" core-nthnext @@ -4080,9 +4063,6 @@ "simple-symbol?" core-simple-symbol? "qualified-keyword?" core-qualified-keyword? "simple-keyword?" core-simple-keyword? - "ident?" core-ident? - "qualified-ident?" core-qualified-ident? - "simple-ident?" core-simple-ident? "inst?" core-inst? "inst-ms" core-inst-ms "uri?" core-uri?