diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-02 22:49:55 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-02 22:52:35 -0400 |
| commit | 5a368128ebd7a2d2f114883d3b6cfbad12913123 (patch) | |
| tree | 72bd5b9fb52a108efefd5834ed65c3517d1f9e87 | |
| parent | c35791a84fe0a34c61704cead61af21dee352efc (diff) | |
Strength reduction: Int, Nat, Range, Match
| -rw-r--r-- | impl.bqn | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -29,6 +29,8 @@ _fold←{ # LAYER 2: Pervasion ToArray ← <⍟(1-IsArray) +Int←IsArray◶⟨⌊⊸=,0⟩ +Nat←IsArray◶⟨0⊸≤×⌊⊸=,0⟩ ∾ ← {k←≠𝕨⋄k⊸≤◶⟨⊑⟜𝕨⋄-⟜k⊑𝕩˜⟩⌜↕k+≠𝕩} # LIMITED to two vector arguments @@ -56,6 +58,14 @@ _perv←{ # Pervasion ⌜ ↩ {𝔽⌜○ToArray} ¨ ↩ {(𝔽⌜)⊘(𝔽_eachd○ToArray)} +match←{(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨ + ⟨=○IsArray, 0⟩ + ⟨IsArray∘⊢, =⟩ + ⟨=○= , 0⟩ + ⟨1×´=¨○≢ , 0⟩ + {1×´⥊𝕨Match¨𝕩} +⟩ + + ↩ + _perv - ↩ - _perv × ↩ (0⊸(<->) ⊘ ×) _perv @@ -68,9 +78,9 @@ _perv←{ # Pervasion ¬ ← 1+- ∧ ← × ∨ ← (+-×) -< ↩ {⟨⟩⥊⟨𝕩⟩} ⊘ ((¬≤˜) _perv) +< ↩ {⟨⟩⥊⟨𝕩⟩} ⊘ ((1-≤˜) _perv) > ↩ > _perv -≠ ↩ ≠ ⊘ (¬∘= _perv) +≠ ↩ ≠ ⊘ ((1-=) _perv) = ↩ = ⊘ (= _perv) ≤ ↩ !∘0 ⊘ (≤ _perv) ≥ ← !∘0 ⊘ (≤˜_perv) @@ -81,9 +91,6 @@ identity ← (0⊑⟨!∘0⟩) {(0⊑𝕨){𝕗=𝕩}◶𝕩‿(1⊑𝕨)}´ ⟨ # LAYER 3: Remove other limits # Now all implementations are full except ∾ and ⊑; ↕ is monadic only -Int←IsArray◶⟨⌊⊸=,0⟩ -Nat←IsArray◶⟨0⊸≤∧⌊⊸=,0⟩ - Deshape←IsArray◶{⟨𝕩⟩}‿⥊ Reshape←{ ! 1≥=𝕨 @@ -103,18 +110,8 @@ Range←{ IsArray◶I‿M 𝕩 } -match←{¬∘(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨ - ⟨≠○IsArray , 0⟩ - ⟨¬IsArray∘⊢, =⟩ - ⟨≠○= , 0⟩ - ⟨∨´≠○≢ , 0⟩ - {∧´⥊𝕨Match¨𝕩} -⟩ - Depth←IsArray◶0‿{1+0⌈´Depth¨⥊𝕩} -↕ ↩ Range - ≡ ← Depth ⊘ Match ≢ ↩ ≢ ⊘ (¬Match) @@ -243,7 +240,7 @@ Indices←{ Rep ← Indices⊸⊏ Replicate ← {0<=𝕨}◶(⥊˜⟜≠Rep⊢)‿{!𝕨=○≠𝕩⋄𝕨Rep𝕩} _onAxes_ (1-0=≠) -↕ ↩ ↕ ⊘ Windows +↕ ↩ Range ⊘ Windows ⌽ ← Reverse ⊘ Rotate / ← Indices ⊘ Replicate |
