From 9543711d3e87382aa8a90810b243754895af149b Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 12 Dec 2020 16:12:46 -0500 Subject: Use Type instead of IsArray in the runtime --- src/pr.bqn | 2 +- src/r.bqn | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/pr.bqn b/src/pr.bqn index 77daed56..a10552a6 100755 --- a/src/pr.bqn +++ b/src/pr.bqn @@ -24,7 +24,7 @@ Inc ← { } # Required functionality passed in as an argument -def ← ⟨"IsArray","Type","Log","GroupLen","GroupOrd"⟩ +def ← ⟨"Type","GetFill","Log","GroupLen","GroupOrd"⟩ keep ← "!+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘" len ⇐ def+○≠keep ki ← chr⊐keep diff --git a/src/r.bqn b/src/r.bqn index d406ffd0..846fbb7c 100644 --- a/src/r.bqn +++ b/src/r.bqn @@ -1,5 +1,5 @@ # BQN runtime. Requires: -# IsArray Type Log GroupLen GroupOrd !+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘ +# Type GetFill Log GroupLen GroupOrd !+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘ ◶ ← {𝕨((𝕨𝔽𝕩)⊑𝕘){𝔽}𝕩} # LIMITED to number left operand result ⊢ ← {𝕩} @@ -12,8 +12,9 @@ ⟜ ← {(𝕨⊣𝕩)𝔽𝔾𝕩} ⍟ ← {𝕨((𝕨𝔾𝕩)⊑⊢‿𝕗){𝔽}𝕩} # LIMITED to boolean right operand result -Int←IsArray◶⟨⌊⊸=,0⟩ -Nat←IsArray◶⟨0⊸≤×⌊⊸=,0⟩ +IsArray←0=Type +Int←(1=Type)◶⟨0,⌊⊸=⟩ +Nat←(1=Type)◶⟨0,0⊸≤×⌊⊸=⟩ Deshape←IsArray◶{⟨𝕩⟩}‿⥊ Pair ← {⟨𝕩⟩} ⊘ {⟨𝕨,𝕩⟩} Box ← {⟨⟩⥊⟨𝕩⟩} @@ -240,7 +241,7 @@ _takeDrop←{ sh ∾↩ t ← (s⊑˜r⊸+)⌜↕(≠s)-r {i 𝕩_c↩ ↕𝕩}⍟(1-1⊸=) k×´t Sel ← ⊑⟜(⥊𝕩) - {Sel↩0⊸≤◶⟨(Type𝕩)˙,Sel⟩}⍟⊢fill + {Sel↩0⊸≤◶⟨(GetFill𝕩)˙,Sel⟩}⍟⊢fill Sel⌜ sh ⥊ i } ToArray 𝕩 } @@ -271,7 +272,7 @@ ShiftAfter←{ } FC←{ # Fill cell "« or »: 𝕩 must have rank at least 1" ! 1≤=𝕩 - (Type 𝕩)⌜ ⥊⟜(↕1×´⊢) 1 Cell 𝕩 + (GetFill 𝕩)⌜ ⥊⟜(↕1×´⊢) 1 Cell 𝕩 } Windows←{ @@ -339,10 +340,10 @@ Reshape←{ Chk ← ⊢ ⊣ "𝕨⥊𝕩: Shape must be exact when reshaping with ∘" ! ⌊⊸= a←(2⌊t)◶⟨Chk,⌊,⌈⟩n÷lp s↩p⊣◶⊢‿a¨s - {d∾↩(Type d)⌜↕𝕩-n⋄n}⍟(n⊸<)⍟(3=t)lp×a + {d∾↩(GetFill d)⌜↕𝕩-n⋄n}⍟(n⊸<)⍟(3=t)lp×a } s s⥊{ - 𝕩(0