From 598071dd983ae2c0fbf11490d243b1ede5bd7ac4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 1 May 2021 13:51:54 -0400 Subject: Various minor improvements --- src/r1.bqn | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/r1.bqn b/src/r1.bqn index f31c03c7..9782c699 100644 --- a/src/r1.bqn +++ b/src/r1.bqn @@ -9,11 +9,13 @@ PrimInd ← {𝕩} SetPrims ← {Decompose‿PrimInd ↩ 𝕩} IsArray ← 0=Type +IsAtom ← 1≤Type Int ← (1=Type)◶⟨0,⌊⊸=⟩ Nat ← (1=Type)◶⟨0,0⊸≤×⌊⊸=⟩ +ToArray ← <⍟IsAtom +IsSimple ← 1×´IsAtom⌜ Deshape ← IsArray◶{𝕩Fill⟨𝕩⟩}‿⥊ Pair ← {⟨𝕩⟩} ⊘ {⟨𝕨,𝕩⟩} -ToArray ← <⍟(1-IsArray) Cell ← ↓⟜≢ MatchS ← 1×´=¨ PermInv ← 1⌜⊸GroupOrd @@ -52,8 +54,8 @@ _eachd←{ } _e←{ # 𝕨 has smaller or equal rank p←≢𝕨 ⋄ k←=𝕨 ⋄ q←≢𝕩 - "Mapping: Argument shape prefixes don't agree" ! 1(⊑⟜p=⊑⟜q)⊸×´↕k - l←1(q⊑˜k⊸+)⊸×´↕(=𝕩)-k + "Mapping: Argument shape prefixes don't agree" ! p MatchS k↑q + l←1×´k↓q a←⥊𝕨 ⋄ b←⥊𝕩 q⥊⥊(≠a) (⊑⟜a𝔽l⊸×⊸+⊑b˙)⌜○↕ l } @@ -108,7 +110,7 @@ Cmp ← +○IsArray◶⟨ _binSearch ← { B ← 𝔽 { - R←{𝕨{a←B m←𝕩+h←⌊𝕨÷2⋄(h+a×𝕨-2×h)R a⊑𝕩‿m}⍟(>⟜1)𝕩} + R←{a←B m←𝕩+h←⌊𝕨÷2⋄(h+a×𝕨-2×h)R a⊑𝕩‿m}⍟(>⟜1) 1+(𝕩+1)R ¯1 }⍟(0⊸<) } @@ -116,7 +118,6 @@ _grade ← { gt ← 𝕗 cmps ← {𝕏˜}⌜⍟𝕗⟨Cmp,Cmp0,Cmp≤0˙,≤⟩ _getC_ ← { 𝕨 𝕘{(𝕨 𝕏 _getCellCmp 𝕗)≤0˙}⍟(𝕩≤1) 𝔽 𝕩⊑cmps } - IsSimple ← 1×´(0