aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-31 13:23:54 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-31 13:24:48 -0400
commite4634b49f32a8040eb1113f7c5f470aec20d8bb6 (patch)
tree770bbf213d4aeba8dae998343b2523282c833b1a
parent1a15fa1cb984dd1d6bd3f5c5b56e0169b1085edf (diff)
Lookup-based ⁼ implementation
-rwxr-xr-xdzref_full3
-rw-r--r--impl.bqn14
-rwxr-xr-xtest/cmpref.bqn3
3 files changed, 18 insertions, 2 deletions
diff --git a/dzref_full b/dzref_full
index 3edbb93d..b6e9e517 100755
--- a/dzref_full
+++ b/dzref_full
@@ -35,8 +35,9 @@ X←Raw←{≤4}
"IsArray ← 0≠≡"
"_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}"
"Type ← ⟨⟩⥊0⊸⥊"
+ "Log ← ⋆⁼"
'!' Mod "{𝕩 ⋄ ≤1}⍟¬"
- ⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼"
+ ⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜"
# checks if line is a builtin redefinition
diff --git a/impl.bqn b/impl.bqn
index 026c03f3..558ef06b 100644
--- a/impl.bqn
+++ b/impl.bqn
@@ -392,6 +392,20 @@ OccurrenceCount ← ⊐˜(⊢-⊏)⍋∘⍋
ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩}
⊒ ← OccurrenceCount⊘ ProgressiveIndexOf
+inverse ← {(⊑(0⊏𝕩)⊐<) ⊑ ((1⊏𝕩)∾⟨!∘0⟩)˜} ⍉ (2∾˜2÷˜≠)⊸⥊ ⟨
+ +, +⊘(-˜)
+ -, -
+ ×, ⊢⊘(÷˜)
+ ÷, ÷
+ ⋆, Log
+ √, ⋆⟜2⊘(⋆˜)
+ ∧, ⊢⊘(÷˜)
+ ∨, ⊢⊘(-˜÷1-⊢)
+ <, {!IsArray𝕩⋄!0==𝕩⋄⊑𝕩}⊘(!∘0)
+ /, {!(⍋≡↕∘≠)𝕩⋄≠¨⊔𝕩}⊘(!∘0)
+⟩
+⁼ ← {Inverse 𝕗}
+
_repeat_←{
n←𝕨𝔾𝕩
l←u←0
diff --git a/test/cmpref.bqn b/test/cmpref.bqn
index 8186889a..86788f81 100755
--- a/test/cmpref.bqn
+++ b/test/cmpref.bqn
@@ -32,8 +32,9 @@ pre ← ⟨
"IsArray ← 0≠≡"
"_amend ← {𝕨{𝕩⋄𝕗}⌾(𝕗⊑⊢)𝕩}"
"Type ← ⟨⟩⥊0⊸⥊"
+ "Log ← ⋆⁼"
'!' Mod "{𝕩 ⋄ ≤1}⍟¬"
-⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜⁼"
+⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜"
# checks if line is a builtin redefinition