apl: ∪ unique / ∪ union / ∩ intersection (+12)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s

- apl-unique: dedup keeping first-occurrence order
- apl-union: dedup'd A then B-elements-not-in-A
- apl-intersect: A elements that are in B, preserves left order
- ∪ wired both monadic and dyadic; ∩ wired dyadic
- pipeline 121/121
This commit is contained in:
2026-05-08 22:42:29 +00:00
parent 8cdebbe305
commit ef53232314
4 changed files with 86 additions and 1 deletions

View File

@@ -497,3 +497,50 @@
"⍸ interval-index: y above all → len breaks"
(mkrv (apl-run "10 20 30 ⍸ 100"))
(list 3)))
(begin
(apl-test
" unique: dedup keeps first-occurrence order"
(mkrv (apl-run " 1 2 1 3 2 1 4"))
(list 1 2 3 4))
(apl-test
" unique: already-unique unchanged"
(mkrv (apl-run " 5 4 3 2 1"))
(list 5 4 3 2 1))
(apl-test " unique: scalar" (mkrv (apl-run " 7")) (list 7))
(apl-test
" unique: string mississippi → misp"
(mkrv (apl-run " 'mississippi'"))
(list "m" "i" "s" "p"))
(apl-test
" union: 1 2 3 3 4 5 → 1 2 3 4 5"
(mkrv (apl-run "1 2 3 3 4 5"))
(list 1 2 3 4 5))
(apl-test
" union: dedups left side too"
(mkrv (apl-run "1 2 1 1 3 2"))
(list 1 2 3))
(apl-test
" union: disjoint → catenated"
(mkrv (apl-run "1 2 3 4"))
(list 1 2 3 4))
(apl-test
"∩ intersection: 1 2 3 4 ∩ 2 4 6 → 2 4"
(mkrv (apl-run "1 2 3 4 ∩ 2 4 6"))
(list 2 4))
(apl-test
"∩ intersection: disjoint → empty"
(mkrv (apl-run "1 2 3 ∩ 4 5 6"))
(list))
(apl-test
"∩ intersection: preserves left order"
(mkrv (apl-run "(5) ∩ 5 3 1"))
(list 1 3 5))
(apl-test
"∩ intersection: identical"
(mkrv (apl-run "1 2 3 ∩ 1 2 3"))
(list 1 2 3))
(apl-test
"/∩ identity: A A = A"
(mkrv (apl-run "1 2 1 1 2 1"))
(list 1 2)))