core: move juxt/every-pred/some-fn to Clojure
Three pure function combinators into the collection tier, as compositions of mapv/every?/some/apply. Three more core-* primitives + table entries gone. Battery 3916 -> 3920 (the canonical defs are more correct than the prior Janet ones — some-fn returns the matching value, every-pred is properly boolean). Conformance 218/218 all modes.
This commit is contained in:
parent
57b8ffcb9b
commit
3638521e2d
3 changed files with 17 additions and 21 deletions
|
|
@ -51,3 +51,13 @@
|
|||
(let [w (first more) kw (k w)]
|
||||
(if (<= kw kv) (recur w kw (next more)) (recur v kv (next more))))
|
||||
v)))))
|
||||
|
||||
;; Function combinators (pure HOFs).
|
||||
(defn juxt [& fs]
|
||||
(fn [& args] (mapv (fn [f] (apply f args)) fs)))
|
||||
|
||||
(defn every-pred [& preds]
|
||||
(fn [& xs] (every? (fn [p] (every? p xs)) preds)))
|
||||
|
||||
(defn some-fn [& preds]
|
||||
(fn [& xs] (some (fn [p] (some p xs)) preds)))
|
||||
|
|
|
|||
|
|
@ -1376,11 +1376,7 @@
|
|||
(table? x) (or (get x :jolt/meta) (get x :meta))
|
||||
nil))
|
||||
|
||||
(defn core-every-pred [& preds]
|
||||
(fn [& xs]
|
||||
(var ok true)
|
||||
(each p preds (each x xs (when (not (truthy? (p x))) (set ok false))))
|
||||
ok))
|
||||
# every-pred now lives in the Clojure collection tier (core/20-coll.clj).
|
||||
|
||||
(def core-comp
|
||||
(fn [& fs]
|
||||
|
|
@ -1401,9 +1397,7 @@
|
|||
(defn core-partial [f & args]
|
||||
(fn [& more] (apply f (array/concat (array/slice args) more))))
|
||||
|
||||
(defn core-juxt [& fs]
|
||||
(fn [& args]
|
||||
(tuple ;(map |(apply $ args) fs))))
|
||||
# juxt now lives in the Clojure collection tier (core/20-coll.clj).
|
||||
|
||||
(defn core-memoize [f]
|
||||
(var cache @{})
|
||||
|
|
@ -3153,11 +3147,7 @@
|
|||
(each x c (array/push r (let [v (core-get smap x :jolt/nf)] (if (= v :jolt/nf) x v))))
|
||||
(tuple/slice (tuple ;r))))
|
||||
|
||||
(defn core-some-fn [& preds]
|
||||
(fn [& xs]
|
||||
(var hit nil)
|
||||
(each p preds (each x xs (when (and (nil? hit) (truthy? (p x))) (set hit (p x)))))
|
||||
hit))
|
||||
# some-fn now lives in the Clojure collection tier (core/20-coll.clj).
|
||||
|
||||
(defn core-sequential? [x] (or (tuple? x) (array? x) (pvec? x) (plist? x) (lazy-seq? x)))
|
||||
# Associative = maps and (real) vectors only. pvec is a literal/built vector;
|
||||
|
|
@ -3733,7 +3723,6 @@
|
|||
"keep" core-keep
|
||||
"interleave" core-interleave
|
||||
"flatten" core-flatten
|
||||
"every-pred" core-every-pred
|
||||
"find" core-find
|
||||
"transduce" core-transduce
|
||||
"sequence" core-sequence
|
||||
|
|
@ -3756,7 +3745,6 @@
|
|||
"rseq" core-rseq
|
||||
"shuffle" core-shuffle
|
||||
"replace" core-replace
|
||||
"some-fn" core-some-fn
|
||||
"sequential?" core-sequential?
|
||||
"associative?" core-associative?
|
||||
"ifn?" core-ifn?
|
||||
|
|
@ -3797,7 +3785,6 @@
|
|||
"complement" core-complement
|
||||
"comp" core-comp
|
||||
"partial" core-partial
|
||||
"juxt" core-juxt
|
||||
"memoize" core-memoize
|
||||
"vector" core-vector
|
||||
"hash-map" core-hash-map
|
||||
|
|
|
|||
|
|
@ -25,11 +25,10 @@
|
|||
# running thread (Janet OS threads can't be interrupted), so `(deref (future
|
||||
# (sleep 1)))` re-raises the unresolved-`Thread/sleep` error — a documented
|
||||
# platform gap, not a regression in any previously-working behavior.
|
||||
# Raised 3913 -> 3916 with the staged-bootstrap kernel tier: the evaluator now
|
||||
# restores current-ns when a fn throws across a try boundary (a leaked ns used to
|
||||
# break referred-symbol resolution after a caught error), and subvec's index
|
||||
# coercion (NaN/float/ratio) is faithful — net +3.
|
||||
(def baseline-pass 3916)
|
||||
# Raised 3913 -> 3916 with the staged-bootstrap kernel tier (ns-restore-on-throw
|
||||
# + faithful subvec coercion), then 3916 -> 3920 moving juxt/every-pred/some-fn to
|
||||
# Clojure (the canonical defs are more correct than the prior Janet ones).
|
||||
(def baseline-pass 3920)
|
||||
# A file is "clean" when it ran with zero failures AND zero errors.
|
||||
(def baseline-clean-files 45)
|
||||
# Per-file wall-clock budget (seconds). Normal files finish in well under 1s;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue