apl: quick-wins bundle — decimals + ⎕← + strings (+10 tests, 460/460)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Three small unblockers in one iteration: - tokenizer: read-digits! now consumes optional ".digits" suffix, so 3.7 and ¯2.5 are single number tokens. - tokenizer: ⎕ followed by ← emits a single :name "⎕←" token (instead of splitting on the assign glyph). Parser registers ⎕← in apl-quad-fn-names; apl-monadic-fn maps to apl-quad-print. - eval-ast: :str AST nodes evaluate to char arrays. Single-char strings become rank-0 scalars; multi-char become rank-1 vectors of single-char strings.
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
((= g "⍋") apl-grade-up)
|
||||
((= g "⍒") apl-grade-down)
|
||||
((= g "⎕FMT") apl-quad-fmt)
|
||||
((= g "⎕←") apl-quad-print)
|
||||
(else (error "no monadic fn for glyph")))))
|
||||
|
||||
(define
|
||||
@@ -97,6 +98,15 @@
|
||||
((tag (first node)))
|
||||
(cond
|
||||
((= tag :num) (apl-scalar (nth node 1)))
|
||||
((= tag :str)
|
||||
(let
|
||||
((s (nth node 1)))
|
||||
(if
|
||||
(= (len s) 1)
|
||||
(apl-scalar s)
|
||||
(make-array
|
||||
(list (len s))
|
||||
(map (fn (i) (slice s i (+ i 1))) (range 0 (len s)))))))
|
||||
((= tag :vec)
|
||||
(let
|
||||
((items (rest node)))
|
||||
|
||||
Reference in New Issue
Block a user