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