From a4de4b3f2d3a0b38588c013e2200f08f100fc1d5 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 28 Apr 2021 13:21:33 -0400 Subject: Use utilities more often; other cleanup --- src/r.bqn | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/r.bqn b/src/r.bqn index e35564f8..9208a598 100644 --- a/src/r.bqn +++ b/src/r.bqn @@ -50,7 +50,7 @@ Cell ← ↓⟜≢ GetCells←(1==∘⊢)◶{ c←1×´s←1 Cell 𝕩 - 𝕨((⥊𝕩)⊑˜c⊸×⊸+)⌜s⥊↕c + (c⊸×⌜𝕨)(+⊑(⥊𝕩)˙)⌜s⥊↕c }‿{ ⊑⟜𝕩⌜𝕨 } _fillBy_ ⊢ @@ -182,7 +182,7 @@ _bins←{ 𝕩↩ToArray 𝕩 lw←1×´sw←1 Cell 𝕨 cw←𝔽○(⊑⟜(⥊𝕨)) _getCellCmp lw - "⍋ or ⍒: 𝕨 must be sorted" ! 0⊸<◶⟨1,1×´·(cw≤0˙)⟜(lw⊸+)∘(lw⊸×)⌜↕∘-⟜1⟩≠𝕨 + "⍋ or ⍒: 𝕨 must be sorted" ! 0⊸<◶⟨1,1×´·(Cw≤0˙)⟜(lw⊸+)∘(lw⊸×)⌜↕∘-⟜1⟩≠𝕨 cx←c-˜=𝕩 sx←cx Cell 𝕩 ⋄ lc←sw CmpLen sx cc ← (⊑⟜(⥊𝕨))⊸𝔽⟜(⊑⟜(⥊𝕩)) _getCellCmp´ lc @@ -236,7 +236,7 @@ Transpose←(0<=)◶⟨ToArray,{ (c⥊↕m)(+⟜(m⊸×)⊑(⥊𝕩)˙)⌜↕l }_fillBy_⊢⟩ TransposeInv←{ - r←1-˜=𝕩 ⋄ s←≢𝕩 ⋄ l←r⊑s ⋄ c←⊑⟜s⌜↕r + r←1-˜=𝕩 ⋄ s←≢𝕩 ⋄ l←r⊑s ⋄ c←r↑s (↕l)(+⟜(l⊸×)⊑(⥊𝕩)˙)⌜c⥊↕1×´c }_fillBy_⊢⍟{IX IsArray𝕩⋄0<=𝕩} @@ -291,7 +291,7 @@ SelSub←{ } First ← IsArray◶⟨⊢, (0<≠)◶⟨Fill,0⊸⊑⟩⥊⟩ -IsPure ← {d←Decompose𝕩 ⋄ 2⊸≤◶⟨≤⟜0, 1(𝕊d⊑˜1⊸+)⊸×´·↕1-˜≠∘d⟩0⊑d} +IsPure ← {d←Decompose𝕩 ⋄ 2⊸≤◶⟨≤⟜0, 1×´·𝕊⌜1↓d˙⟩0⊑d} _fillByPure_←{ 𝕘 (3≤Type∘⊣)◶⟨{𝕨Fill𝕏},{(𝕨HomFil𝕩)_fillBy_𝕨}⍟(IsPure⊣)⟩ 𝕗 } @@ -388,7 +388,7 @@ JoinM←{ a←𝕩⊑sh m←𝕩⊸⊑⌜s l←(q⊸×⊑m˙)⌜↕a - "∾𝕩: 𝕩 element shapes must be compatible" ! 1×´m=¨⥊(↕p)⊢⌜l⊣⌜↕q + "∾𝕩: 𝕩 element shapes must be compatible" ! m MatchS ⥊(↕p)⊢⌜l⊣⌜↕q k ← Indices l c ← -⟜(⊑⟜(k ⊏ 0+_s0 l))⌜ ↕≠k i ↩ (i ×⟜(⊑⟜l)⌜ k) +¨ i⊢⌜c @@ -397,9 +397,8 @@ JoinM←{ }¨↕r G←(⥊⌜z){𝕨⊑𝕩⊑𝕗}¨ i (r