835ea6ca7d
This one is not finished yet, but needs to move of this laptop by ways of git. Change-Id: I2c8c0a7b581a654f7cfab92dd21ced82a14c5f42 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7616 Tested-by: BuildkiteCI Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: sterni <sternenseemann@systemli.org>
25 lines
785 B
BQN
25 lines
785 B
BQN
⟨ImportBqnLibs, IsAsciiNum, ReadDec⟩ ← •Import "../../lib.bqn"
|
||
⟨ReplaceAll, Split⟩ ← ImportBqnLibs "strings.bqn"
|
||
|
||
i ← ": "⊸Split¨ •FLines "input"
|
||
ReplaceInts ← {
|
||
𝕊 𝕩: 𝕊´ 2↑(¬∘(∧´IsAsciiNum∘⊑∘⌽)¨⊔⊢) 𝕩;
|
||
# TODO: Efficient replace on tokens
|
||
is 𝕊 es: (((•Fmt⍟(0⊸≠•Type))¨⌾(1⊸⊑) <˘⍉>is)⊸ReplaceAll⌾(1⊸⊑))¨ es
|
||
}
|
||
|
||
c ← 0
|
||
CanEval ← (IsAsciiNum∨∊⟜"+-/* ")
|
||
Eval ← {
|
||
a‿s‿b ← " " Split 𝕩
|
||
f ← ⊑+‿-‿×‿÷⊏˜"+-*/"⊐s
|
||
a F○ReadDec b
|
||
}
|
||
EvalExprs ← {
|
||
p‿e ← 2↑((∧´CanEval∘⊑∘⌽)¨⊔⊢) 𝕩
|
||
ev ← (Eval⌾(⊑⌽))¨ e
|
||
c +↩1
|
||
(⊑(⊑¨ev)∊˜<"root")◶⟨EvalExprs∘(ReplaceInts⟜p),1⊸⊑⊑⟩ ev
|
||
}
|
||
|
||
•Show EvalExprs ReplaceInts i
|