diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-29 18:08:24 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-29 18:08:24 -0400 |
| commit | 1461cb3b0dcf4991295ecffa7317ae0c4a7a909c (patch) | |
| tree | 7e04a6b27849fd5e56fbd259227157768d320ba2 | |
| parent | 48d8cc1401e46b8c33330f0f61fd36b40c20b789 (diff) | |
Don't include undefined built-in guards in preprocessing
| -rwxr-xr-x | dzref | 16 | ||||
| -rwxr-xr-x | dzref_full | 20 | ||||
| -rw-r--r-- | impl.bqn | 6 | ||||
| -rwxr-xr-x | test/cmpref.bqn | 22 |
4 files changed, 26 insertions, 38 deletions
@@ -150,23 +150,19 @@ X←Raw←{≤4} post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 names ← init∾¨(•UCS 48)∾¨post - Inc ← { + Inc ← { i←⊑chr⊐𝕩 n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr names↩((i⊑init)∾(•UCS 48+n)∾i⊑post)⌾(i⊑⊢)names } - # starting built-ins - inps←⟨"𝕨 ","𝕨,𝕗","𝕨,𝕘"⟩ - ⍎¨names∾¨(nc/("←{⟨"∾∾⟜"⟩ ⋄ ⍎""Using undefined built-in ")¨inps)∾¨∾⟜"""}"¨chr - # built-in assumptions - Mod ← ⍎{𝔽 ((⊑chr⊐𝕨)⊑names) ∾ " ↩ " ∾ 𝕩} - - ⍎"IsArray ← 0≠≡" + Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} - '!' Mod "{𝕩 ⋄ ≤1}⍟¬" - Mod⟜⥊¨ "↕∾⌽⊐⍋⍒" + ⍎¨ ⟨ + "IsArray ← 0≠≡" + '!' Mod "{𝕩 ⋄ ≤1}⍟¬" + ⟩∾Mod⟜⥊¨ "↕∾⌽⊐⍋⍒" # checks if line is a builtin redefinition @@ -22,25 +22,21 @@ X←Raw←{≤4} post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 names ← init∾¨(•UCS 48)∾¨post - Inc ← { + Inc ← { i←⊑chr⊐𝕩 n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr names↩((i⊑init)∾(•UCS 48+n)∾i⊑post)⌾(i⊑⊢)names } - # starting built-ins - inps←⟨"𝕨 ","𝕨,𝕗","𝕨,𝕘"⟩ - ⍎¨names∾¨(nc/("←{⟨"∾∾⟜"⟩ ⋄ ⍎""Using undefined built-in ")¨inps)∾¨∾⟜"""}"¨chr - # built-in assumptions - Mod ← ⍎{𝔽 ((⊑chr⊐𝕨)⊑names) ∾ " ↩ " ∾ 𝕩} - - ⍎"IsArray ← 0≠≡" - ⍎"_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}" - ⍎"Type ← ⟨⟩⥊0⊸⥊" + Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} - '!' Mod "{𝕩 ⋄ ≤1}⍟¬" - Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼" + ⍎¨ ⟨ + "IsArray ← 0≠≡" + "_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}" + "Type ← ⟨⟩⥊0⊸⥊" + '!' Mod "{𝕩 ⋄ ≤1}⍟¬" + ⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼" # checks if line is a builtin redefinition @@ -383,13 +383,13 @@ _bins←{ (≠𝕨) {B⟜𝕩 _binSearch 𝕨}¨ (×´sx) × ⥊⟜(↕×´)⊑⟜(≢𝕩)¨↕cx } -OccurrenceCount ← ⊐˜(⊢-⊏)⍋∘⍋ -ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩} - ⍋ ← Cmp _grade ⊘ ( Cmp _bins) ⍒ ← -∘Cmp _grade ⊘ (-∘Cmp _bins) ∧ ↩ ⍋⊸⊏ ⊘ ∧ ∨ ↩ ⍒⊸⊏ ⊘ ∨ + +OccurrenceCount ← ⊐˜(⊢-⊏)⍋∘⍋ +ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩} ⊒ ← OccurrenceCount⊘ ProgressiveIndexOf _repeat_←{ diff --git a/test/cmpref.bqn b/test/cmpref.bqn index 54b3eabd..fb02a664 100755 --- a/test/cmpref.bqn +++ b/test/cmpref.bqn @@ -19,25 +19,21 @@ init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"A post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 names ← init∾¨(•UCS 48)∾¨post -Inc ← { +Inc ← { i←⊑chr⊐𝕩 n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr names↩((i⊑init)∾(•UCS 48+n)∾i⊑post)⌾(i⊑⊢)names } -# starting built-ins -inps←⟨"𝕨 ","𝕨,𝕗","𝕨,𝕘"⟩ -pre ← names∾¨(nc/("←{⟨"∾∾⟜"⟩ ⋄ ≤""Using undefined built-in ")¨inps)∾¨∾⟜"""}"¨chr - # built-in assumptions -Mod ← {pre ∾↩ <((⊑chr⊐𝕨)⊑names) ∾ " ↩ " ∾ 𝕩} - -pre ∾↩ <"IsArray ← 0≠≡" -pre ∾↩ <"_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}" -pre ∾↩ <"Type ← ⟨⟩⥊0⊸⥊" - -'!' Mod "{𝕩 ⋄ ≤1}⍟¬" -Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼" +Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} + +pre ← ⟨ + "IsArray ← 0≠≡" + "_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}" + "Type ← ⟨⟩⥊0⊸⥊" + '!' Mod "{𝕩 ⋄ ≤1}⍟¬" +⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼" # checks if line is a builtin redefinition |
