apl: ⊆ partition — mask-driven split (+8)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s

- apl-partition: new partition where M[i]>M[i-1] (init prev=0);
  continue where M[i]≤prev∧M[i]≠0; drop cells where M[i]=0
- Returns apl-vector of apl-vector parts
- pipeline 140/140
This commit is contained in:
2026-05-08 22:55:01 +00:00
parent a074ea9e98
commit 015ecb8bc8
4 changed files with 54 additions and 1 deletions

View File

@@ -590,3 +590,40 @@
"⊥ decode: round-trip B(B⊥V) = V"
(mkrv (apl-run "2 2 2 2 2 2 ⊥ 1 0 1"))
(list 1 0 1)))
(begin
(define
mk-parts
(fn (s) (map (fn (p) (get p :ravel)) (get (apl-run s) :ravel))))
(apl-test
"⊆ partition: 1 1 0 1 1 ⊆ 'abcde' → ('ab' 'de')"
(mk-parts "1 1 0 1 1 ⊆ 'abcde'")
(list (list "a" "b") (list "d" "e")))
(apl-test
"⊆ partition: 1 0 0 1 1 ⊆ 5 → ((1) (4 5))"
(mk-parts "1 0 0 1 1 ⊆ 5")
(list (list 1) (list 4 5)))
(apl-test
"⊆ partition: all-zero mask → empty"
(len (get (apl-run "0 0 0 ⊆ 1 2 3") :ravel))
0)
(apl-test
"⊆ partition: all-one mask → single partition"
(mk-parts "1 1 1 ⊆ 7 8 9")
(list (list 7 8 9)))
(apl-test
"⊆ partition: strict increase 1 2 starts new"
(mk-parts "1 2 ⊆ 10 20")
(list (list 10) (list 20)))
(apl-test
"⊆ partition: same level continues 2 2 → one partition"
(mk-parts "2 2 ⊆ 10 20")
(list (list 10 20)))
(apl-test
"⊆ partition: 0 separates"
(mk-parts "1 1 0 0 1 ⊆ 1 2 3 4 5")
(list (list 1 2) (list 5)))
(apl-test
"⊆ partition: outer length matches partition count"
(len (get (apl-run "1 0 1 0 1 ⊆ 5") :ravel))
3))