core: move nthrest/abs/NaN?/object?/undefined?/keyword-identical? to overlay

Fifth pure-fn batch (jolt-1j0 phase 2), 6 leaf fns. nthrest uses the canonical
loop form (same neutral 13/1/0 on nthrest.cljc as the prior Janet version; the
1 fail is a pre-existing platform-conditional case). object?/undefined? are
always false on Jolt.

conformance 218/218 x3, clojure-test-suite 3928, core-bench A/B noise-only.
This commit is contained in:
Yogthos 2026-06-06 23:34:31 -04:00
parent 4aec21e603
commit 185cf30c1d
2 changed files with 19 additions and 18 deletions

View file

@ -121,3 +121,22 @@
(defn completing
([f] (completing f identity))
([f cf] (fn ([] (f)) ([x] (cf x)) ([x y] (f x y)))))
;; Canonical loop form: short-circuits on an empty/nil coll before examining n
;; (so (nthrest nil n) is nil without a number check), matching Clojure.
(defn nthrest [coll n]
(loop [n n xs coll]
(if (and (pos? n) (seq xs))
(recur (dec n) (rest xs))
xs)))
(defn abs [x] (if (neg? x) (- 0 x) x))
(defn NaN? [x]
(if (number? x) (not (= x x)) (throw (str "NaN? requires a number"))))
;; No distinct host object / undefined types on Jolt.
(defn object? [x] false)
(defn undefined? [x] false)
(defn keyword-identical? [a b] (= a b))