diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-28 14:01:15 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-28 14:01:15 -0400 |
| commit | 5199bc3835b6509f01560660750cd102cd5cf033 (patch) | |
| tree | b4a114fa0fc251be7b8b025094c9a166fb2c48c3 /src/r0.bqn | |
| parent | a4de4b3f2d3a0b38588c013e2200f08f100fc1d5 (diff) | |
Split r.bqn into r0.bqn and r1.bqn, but compile as one unit
Diffstat (limited to 'src/r0.bqn')
| -rw-r--r-- | src/r0.bqn | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/r0.bqn b/src/r0.bqn new file mode 100644 index 00000000..2dc08d62 --- /dev/null +++ b/src/r0.bqn @@ -0,0 +1,47 @@ +# BQN runtime part 0. Requires: +# Fill _fillBy_ +# +-×⌊=≤≢⥊⊑↕⌜ +# Provides: +# ⌊⌈|<>≠≥⊢⊣∾↑↓⊏˙˜´∘○⊸⟜◶⍟ +# ^^^^^^^ ^^^^ ^ ^^ are limited, suitable for r1 + +⊢ ← {𝕩} +⊣ ← {𝕩}⊘{𝕨} +˙ ← {𝕩⋄𝕗} +˜ ← {𝕩𝔽𝕨⊣𝕩} +∘ ← {𝔽𝕨𝔾𝕩} +○ ← {(𝔾𝕨)𝔽𝔾𝕩} +⊸ ← {(𝔽𝕨⊣𝕩)𝔾𝕩} +⟜ ← {(𝕨⊣𝕩)𝔽𝔾𝕩} +◶ ← {𝕨((𝕨𝔽𝕩)⊑𝕘){𝔽}𝕩} # LIMITED to number left operand result +⍟ ← {𝕨((𝕨𝔾𝕩)⊑⊢‿𝕗){𝔽}𝕩} # LIMITED to boolean right operand result + +Box ← {𝕩Fill⟨⟩⥊⟨𝕩⟩} +# LIMITED to numeric arguments for arithmetic cases +≥ ← ≤˜ +< ← Box ⊘ (1-≥) +> ← (1-≤) +⌊ ↩ ⌊ ⊘ (⊣-≥×-) +⌈ ← -∘⌊∘- ⊘ (⊣-≤×-) +| ← 0⊸≤◶-‿⊢ +≠ ← (0<=)◶⟨1⋄0⊑≢⟩ # LIMITED to monadic case + +∾ ← {k←≠𝕨⋄k⊸≤◶⟨⊑⟜𝕨⋄-⟜k⊑𝕩˜⟩⌜↕k+≠𝕩} # LIMITED to two list arguments +↑ ← {⊑⟜𝕩⌜↕𝕨} # LIMITED to number 𝕨 and list 𝕩 +↓ ← {(𝕨⊸+⊑𝕩˙)⌜↕(≠𝕩)-𝕨} # LIMITED to number 𝕨 and list 𝕩 + +_fold0←{ + l←≠𝕩 ⋄ F←𝔽 + r←𝕨 {l↩l-1⋄l⊑𝕩}⊘⊣ 𝕩 + ({r↩𝕩 F r}(l-1)⊸-⊑𝕩˙)⌜↕l + r +} +´ ← _fold0 # LIMITED to nonempty list 𝕩, or 𝕨 and list 𝕩 + +GetCells←(1==∘⊢)◶{ + c←1×´s←1↓≢𝕩 + (c⊸×⌜𝕨)(+⊑(⥊𝕩)˙)⌜s⥊↕c +}‿{ + ⊑⟜𝕩⌜𝕨 +} _fillBy_ ⊢ +⊏ ← GetCells # LIMITED to depth-1 natural number left argument |
