diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-01 10:53:39 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-01 10:55:44 -0400 |
| commit | 86b69992eaeec3622b914990ddecf432b227f87f (patch) | |
| tree | f26d46fad33d9707b136ed75bbc215dfab9a349d /src | |
| parent | ca5424b343e70f2b6f0080cb3c031600a1883550 (diff) | |
Implement shifts with Take/Drop then Join
Diffstat (limited to 'src')
| -rw-r--r-- | src/r1.bqn | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -489,20 +489,17 @@ ShiftCheck←{ "« or »: Rank of 𝕨 must be at least rank of 𝕩 minus 1" ! 1≥𝕩 "« or »: 𝕨 must share 𝕩's major cell shape" ! s MatchS (1-𝕩)↓≢𝕨 } 𝕩-○=𝕨 - 1×´s + (𝕨1⊘{(𝕩≤○=⊢)◶1‿≠𝕨}𝕩) ×´ s } -ShiftLen←1⊘{(𝕩≤○=⊢)◶1‿≠𝕨} ShiftBefore←{ - c←𝕨 ShiftCheck 𝕩 - n←c×𝕨 ShiftLen 𝕩 - (≢𝕩)⥊n⊸≤◶⟨𝕨Fill⊘{⊑⟜(Deshape𝕨)}𝕩, -⟜n⊑(⥊𝕩)˙⟩⌜ ↕c×≠𝕩 + n←𝕨 ShiftCheck 𝕩 + m←n⌊l←≠d←⥊𝕩 + (≢𝕩) ⥊ (𝕨{(Fill𝕩)⌜↕𝕨}⟜𝕩⊘(↑⟜Deshape˜)m) ∾ (l-m)↑d } _fillBy_ (⊢⊘IF) ShiftAfter←{ - c←𝕨 ShiftCheck 𝕩 - l←c×≠𝕩 - n←c×𝕨 ShiftLen 𝕩 - m←l-n - (≢𝕩)⥊m⊸≤◶⟨+⟜n⊑(⥊𝕩)˙, 𝕨Fill⊘{-⟜m⊑(Deshape𝕨)˙}𝕩⟩⌜ ↕l + n←𝕨 ShiftCheck 𝕩 + m←n⌊≠d←⥊𝕩 + (≢𝕩) ⥊ (m↓d) ∾ 𝕨{(Fill𝕩)⌜↕𝕨}⟜𝕩⊘(n⊸-⊸↓⟜Deshape˜)m } _fillBy_ (⊢⊘IF) Range←{ |
