From 69078a59a95f3e5273f09dd10b5ee75ee5576b76 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 7 May 2026 23:50:28 +0000 Subject: [PATCH] =?UTF-8?q?apl:=20glyph=20audit=20=E2=80=94=20=E2=8D=89=20?= =?UTF-8?q?=E2=8A=A2=20=E2=8A=A3=20=E2=8D=95=20wired=20(+6=20tests,=20Phas?= =?UTF-8?q?e=209=20complete)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Glyph parser saw these but runtime had no mapping: - ⍉ monadic + dyadic transpose (apl-transpose, apl-transpose-dyadic) - ⊢ monadic identity / dyadic right (returns ⍵) - ⊣ monadic identity / dyadic left (returns ⍺) - ⍕ alias for ⎕FMT Pipeline 99/99. All Phase 9 items ticked. Remaining gaps (next phase): ⊆ partition, ∪ unique, ∩ intersection, ⍸ where, ⊥ decode, ⊤ encode, ⍎ execute — parser recognises them but runtime not yet implemented. --- lib/apl/tests/pipeline.sx | 24 ++++++++++++++++++++++++ lib/apl/transpile.sx | 7 +++++++ plans/apl-on-sx.md | 7 ++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/apl/tests/pipeline.sx b/lib/apl/tests/pipeline.sx index 0d9b3e3f..2d21bfb6 100644 --- a/lib/apl/tests/pipeline.sx +++ b/lib/apl/tests/pipeline.sx @@ -431,3 +431,27 @@ (file-read "lib/apl/tests/programs/primes.apl") " ⋄ primes 100")))) 25) + +(apl-test + "⍉ monadic transpose 2x3 → 3x2" + (mkrv (apl-run "⍉ (2 3) ⍴ ⍳6")) + (list 1 4 2 5 3 6)) + +(apl-test + "⍉ transpose shape (3 2)" + (mksh (apl-run "⍉ (2 3) ⍴ ⍳6")) + (list 3 2)) + +(apl-test "⊢ monadic identity" (mkrv (apl-run "⊢ 1 2 3")) (list 1 2 3)) + +(apl-test + "5 ⊣ 1 2 3 → 5 (left)" + (mkrv (apl-run "5 ⊣ 1 2 3")) + (list 5)) + +(apl-test + "5 ⊢ 1 2 3 → 1 2 3 (right)" + (mkrv (apl-run "5 ⊢ 1 2 3")) + (list 1 2 3)) + +(apl-test "⍕ 42 → \"42\" (alias for ⎕FMT)" (apl-run "⍕ 42") "42") diff --git a/lib/apl/transpile.sx b/lib/apl/transpile.sx index 12a5a99d..d5b50148 100644 --- a/lib/apl/transpile.sx +++ b/lib/apl/transpile.sx @@ -40,6 +40,10 @@ ((= g "⍋") apl-grade-up) ((= g "⍒") apl-grade-down) ((= g "?") apl-roll) + ((= g "⍉") apl-transpose) + ((= g "⊢") (fn (a) a)) + ((= g "⊣") (fn (a) a)) + ((= g "⍕") apl-quad-fmt) ((= g "⎕FMT") apl-quad-fmt) ((= g "⎕←") apl-quad-print) (else (error "no monadic fn for glyph"))))) @@ -83,6 +87,9 @@ ((= g "~") apl-without) ((= g "/") apl-compress) ((= g "⌿") apl-compress-first) + ((= g "⍉") apl-transpose-dyadic) + ((= g "⊢") (fn (a b) b)) + ((= g "⊣") (fn (a b) a)) (else (error "no dyadic fn for glyph"))))) (define diff --git a/plans/apl-on-sx.md b/plans/apl-on-sx.md index b358d781..616d71ca 100644 --- a/plans/apl-on-sx.md +++ b/plans/apl-on-sx.md @@ -218,10 +218,14 @@ Today they are documentation; we paraphrase the algorithms in _(primes.apl runs as-written with ⍵-rebind now supported. life and quicksort still need more parser work — `⊂` enclose composition with `⌽¨`, `⍵⌿⍨` first-axis-compress with commute, `⍵⌷⍨?≢⍵`.)_ -- [ ] **Audit silently-skipped glyphs** — sweep `apl-glyph-set` and +- [x] **Audit silently-skipped glyphs** — sweep `apl-glyph-set` and `apl-parse-fn-glyphs` against the runtime's `apl-monadic-fn` and `apl-dyadic-fn` cond chains to find any that the runtime supports but the parser doesn't see. + _(Wired ⍉ → apl-transpose / apl-transpose-dyadic, ⊢ identity, + ⊣ left, ⍕ as alias for ⎕FMT. ⊆ ∪ ∩ ⍸ ⊥ ⊤ ⍎ remain unimplemented + in the runtime — parser sees them as functions but eval errors; + next-phase work.)_ ## SX primitive baseline @@ -237,6 +241,7 @@ data; format for string templating. _Newest first._ +- 2026-05-07: Phase 9 step 6 — glyph audit. Wired ⍉ → apl-transpose/apl-transpose-dyadic, ⊢ → monadic+dyadic identity-right, ⊣ → identity-left, ⍕ → apl-quad-fmt. +6 tests; **Phase 9 complete, all unchecked items ticked**; pipeline 99/99 - 2026-05-07: Phase 9 step 5 — primes.apl runs as-written end-to-end. Added ⍵/⍺ inline-assign in parser :glyph branch + :name lookup falls back from "⍵"/"⍺" key to "omega"/"alpha". `apl-run "primes ← {(2=+⌿0=⍵∘.|⍵)/⍵←⍳⍵} ⋄ primes 50"` → 15 primes. +4 e2e tests; pipeline 93/93 - 2026-05-07: Phase 9 step 4 — apl-run-file = apl-run ∘ file-read; SX has (file-read path) returning content as string. primes/life/quicksort .apl files now load and parse end-to-end (return :dfn AST). +4 tests - 2026-05-07: Phase 9 step 3 — `?N` random / roll. Top-level mutable apl-rng-state with LCG; apl-rng-seed! for deterministic tests; apl-roll wraps as scalar in 1..N. apl-monadic-fn maps "?" → apl-roll. +4 tests (deterministic with seed 42, range checks)