From 86b69992eaeec3622b914990ddecf432b227f87f Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 1 May 2021 10:53:39 -0400 Subject: Implement shifts with Take/Drop then Join --- src/r1.bqn | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/r1.bqn b/src/r1.bqn index 5cca7041..30c4e410 100644 --- a/src/r1.bqn +++ b/src/r1.bqn @@ -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←{ -- cgit v1.2.3