core: zero?/pos?/every? to 00-syntax, char? to the overlay; fix rest/next over sets and maps
Round 4 of the seed shrink. zero?, pos?, every? move to the syntax tier
(empty? and the analyzer use them — raw def+fn* per the file constraint);
char? joins the tagged-value predicates in 20-coll. coll? stays seed: host
set? doesn't cover sorted sets (filed jolt-dpn) and the tag check from the
overlay would hit the sorted-coll get trap. pos? guards number? explicitly —
the staged recompile emits bare > as the native janet op, which orders
strings (zero? gets the same guard; spec rows lock both plus neg?).
The canonical every? seq-walks its coll, which exposed that rest/next over
sets, phms, struct maps and sorted colls fell into core-rest's indexed
fall-through and walked the wrapper table's INTERNAL fields — (next #{1 2})
was (nil nil), (clojure.set/subset?) broke. core-rest now seqs those
representations (branches placed AFTER the hot vector/lazy paths; the first
ordering cost seq-pipe 4x). Suite rises 4700 -> 4703; baseline 4660 -> 4695.
even?/odd? are back in the seed after the bench A/B: (filter even? ...) pays
an extra call layer per element through the overlay (seq-pipe 262 -> 1100ms).
They join the perf-wall list with the lazy hot fns.
This commit is contained in:
parent
407d656240
commit
a1a9fd9949
6 changed files with 97 additions and 37 deletions
|
|
@ -205,3 +205,25 @@
|
|||
["string NOT" "false" "(ifn? \"s\")"]
|
||||
["number NOT" "false" "(ifn? 5)"]
|
||||
["nil NOT" "false" "(ifn? nil)"])
|
||||
|
||||
# zero?/pos? throw on non-numbers (Numbers.isZero/isPos), as in Clojure;
|
||||
# every? short-circuits on the first falsey pred result, so an infinite seq
|
||||
# with an early counterexample terminates. char? is the tagged-value check.
|
||||
(defspec "predicates / numeric guards & every? (overlay moves)"
|
||||
["zero? zero" "true" "(zero? 0)"]
|
||||
["zero? nonzero" "false" "(zero? 3)"]
|
||||
["zero? throws" :throws "(zero? :a)"]
|
||||
["zero? throws on nil" :throws "(zero? nil)"]
|
||||
["pos? positive" "true" "(pos? 2)"]
|
||||
["pos? zero" "false" "(pos? 0)"]
|
||||
["pos? throws" :throws "(pos? \"x\")"]
|
||||
["neg? throws" :throws "(neg? \"x\")"]
|
||||
["every? all pass" "true" "(every? odd? [1 3 5])"]
|
||||
["every? one fails" "false" "(every? odd? [1 2 5])"]
|
||||
["every? vacuous" "true" "(every? odd? [])"]
|
||||
["every? nil coll" "true" "(every? odd? nil)"]
|
||||
["every? infinite short-circuit" "false" "(every? pos? (range))"]
|
||||
["char? char" "true" "(char? \\x)"]
|
||||
["char? string" "false" "(char? \"x\")"]
|
||||
["char? number" "false" "(char? 97)"]
|
||||
["char? nil" "false" "(char? nil)"])
|
||||
|
|
|
|||
|
|
@ -290,3 +290,20 @@
|
|||
"(loop [xs (seq (vec (range 20000))) n 0] (if xs (recur (next xs) (inc n)) n))"]
|
||||
["mapv scales (50k linear)" "50000" "(count (mapv inc (vec (range 50000))))"]
|
||||
["nested walk" "[2 3]" "(vec (rest (mapv inc [0 1 2])))"])
|
||||
|
||||
# rest/next over sets, maps, and sorted colls used to fall into the indexed
|
||||
# fall-through and walk the wrapper table's internal fields ((next #{1 2})
|
||||
# was (nil nil)) — exposed when the canonical every? started seq-walking.
|
||||
(defspec "sequences / rest & next over set-like colls"
|
||||
["next of set" "true" "(let [n (next #{1 2})] (and (= 1 (count n)) (contains? #{1 2} (first n))))"]
|
||||
["rest of set count" "1" "(count (rest #{1 2}))"]
|
||||
["next of singleton set" "nil" "(next #{1})"]
|
||||
["rest of empty set" "0" "(count (rest #{}))"]
|
||||
["next of map" "true" "(let [n (next {:a 1 :b 2})] (and (= 1 (count n)) (map-entry? (first n))))"]
|
||||
["next of singleton map" "nil" "(next {:a 1})"]
|
||||
["rest of sorted-set" "(quote (2 3))" "(rest (sorted-set 3 1 2))"]
|
||||
["next of sorted-map" "(quote ([2 :b]))" "(next (sorted-map 1 :a 2 :b))"]
|
||||
["every? over set" "true" "(every? pos? #{1 2 3})"]
|
||||
["every? over set false" "false" "(every? odd? #{1 2})"]
|
||||
["every? over sorted-set" "true" "(every? pos? (sorted-set 1 2 3))"]
|
||||
["every? over map entries" "true" "(every? map-entry? (seq {:a 1 :b 2}))"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue