apl: multi-axis bracket A[I;J] / A[I;] / A[;J] (+8 tests, 475/475)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
Parser: split-bracket-content splits inner tokens on :semi at depth 0; maybe-bracket emits (:bracket arr axis-exprs...) for multi-axis access, with :all marker for empty axes. Runtime: apl-bracket-multi enumerates index combinations via apl-cartesian (helper) and produces sub-array. Scalar axes collapse from result shape; vector / nil axes contribute their length. apl-run "M ← (3 3) ⍴ ⍳9 ⋄ M[2;2]" → 5 apl-run "M ← (3 3) ⍴ ⍳9 ⋄ M[1;]" → 1 2 3 apl-run "M ← (3 3) ⍴ ⍳9 ⋄ M[;2]" → 2 5 8 apl-run "M ← (2 3) ⍴ ⍳6 ⋄ M[1 2;1 2]" → 2x2 sub-block
This commit is contained in:
@@ -149,6 +149,16 @@
|
||||
(apl-eval-ast rhs env)))))
|
||||
((= tag :program) (apl-eval-stmts (rest node) env))
|
||||
((= tag :dfn) node)
|
||||
((= tag :bracket)
|
||||
(let
|
||||
((arr-expr (nth node 1)) (axis-exprs (rest (rest node))))
|
||||
(let
|
||||
((arr (apl-eval-ast arr-expr env))
|
||||
(axes
|
||||
(map
|
||||
(fn (a) (if (= a :all) nil (apl-eval-ast a env)))
|
||||
axis-exprs)))
|
||||
(apl-bracket-multi axes arr))))
|
||||
(else (error (list "apl-eval-ast: unknown node tag" tag node)))))))
|
||||
|
||||
(define
|
||||
|
||||
Reference in New Issue
Block a user