c381fa64cf
I cheated a bit to skip implementing multi cycle instructions. The VM is pretty much a normal tail recursive function, but working with scalars in BQN is on brand-ish. Array programming helps again when drawing the picture on screen. Change-Id: I2562c862e228f633c5fad09e503529c6e0785112 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7556 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org>
13 lines
372 B
BQN
13 lines
372 B
BQN
IsAsciiNum ⇐ ('0'⊸≤∧≤⟜'9')
|
||
|
||
# based on leah2's function
|
||
ReadInt ⇐ {
|
||
𝕨 𝕊 𝕩: '-'=⊑𝕩? -𝕨 𝕊 1↓𝕩;
|
||
𝕨 𝕊 𝕩: (𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩
|
||
}
|
||
ReadDec ⇐ 10⊸ReadInt
|
||
|
||
SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
|
||
SplitAt ← ((⊣≤↕∘≠∘⊢)⊔⊢)
|
||
|
||
_fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩}
|