diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-17 16:33:36 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-17 16:33:36 -0500 |
| commit | d9c56581877376cb12c6b6c319fb4fc1714564c0 (patch) | |
| tree | 830d832fbaf3dc131d5ce94f2b6cba2cf1c115d4 | |
| parent | 23f0e74e70c01f3850b94d56c7145b0bd9e63f61 (diff) | |
Fix errors in reference function testing up to layer 3
| -rw-r--r-- | spec/reference.bqn | 32 | ||||
| -rw-r--r-- | src/pp.bqn | 2 | ||||
| -rw-r--r-- | test/ref.bqn | 4 |
3 files changed, 25 insertions, 13 deletions
diff --git a/spec/reference.bqn b/spec/reference.bqn index ad6bf923..62c790ac 100644 --- a/spec/reference.bqn +++ b/spec/reference.bqn @@ -26,7 +26,7 @@ ≤ # Less Than or Equal to # Other basic functionality that we need to assume -IsArray # Return 1 if 𝕩 is an array +Type # 0 if 𝕩 is an array, 1 if a number, >1 otherwise ! # 𝕩 is 0 or 1; throw an error if it's 0 ≢ # LIMITED to monadic case ⥊ # LIMITED to array 𝕩 and (×´𝕨)≡≢𝕩 @@ -52,7 +52,9 @@ Fill # Enclosed fill value for 𝕩 ○ ← {(𝔾𝕨)𝔽𝔾𝕩} ⊸ ← {(𝔽𝕨⊣𝕩)𝔾𝕩} ⟜ ← {(𝕨⊣𝕩)𝔽𝔾𝕩} +⍟ ← {𝕨𝔾◶⊢‿𝔽𝕩} # LIMITED to boolean right operand result +IsArray←0=Type ≢ ↩ IsArray◶⟨⟩‿≢ # LIMITED to monadic case # LIMITED to numeric arguments for arithmetic cases @@ -81,10 +83,18 @@ _eachm←{ E←(≠r)⊸≤◶{r↩r𝕩_amend˜F𝕩⊑r⋄E𝕩+1}‿⊢ E 0 ⋄ (≢𝕩)⥊r } +id ← {(0⊑𝕨)˙⊸=◶𝕩‿(1⊑𝕨)}´ ⟨ + ×‿1, ¬‿1 + ⌊‿∞ , ⌈‿¯∞ + ∨‿0 , ∧‿1 + ≠‿0 , =‿1 + >‿0 , ≥‿1 + Identity +⟩ _fold←{ ! 1==𝕩 l←≠v←𝕩 ⋄ F←𝔽 - r←𝕨 (0<l)◶{𝕩⋄Identity f}‿{l↩l-1⋄l⊑𝕩}⊘⊣ 𝕩 + r←𝕨 (0<l)◶{𝕩⋄Id f}‿{l↩l-1⋄l⊑𝕩}⊘⊣ 𝕩 {r↩(𝕩⊑v)F r}¨(l-1)⊸-¨↕l r } @@ -128,8 +138,8 @@ _perv←{ # Pervasion # LAYER 3: Remove other limits # Now all implementations are full except ∾; ↕ is monadic only -Int←IsArray◶⟨⌊⊸=,0⟩ -Nat←IsArray◶⟨0⊸≤∧⌊⊸=,0⟩ +Int←(1=Type)◶⟨0,⌊⊸=⟩ +Nat←(1=Type)◶⟨0,0⊸≤×⌊⊸=⟩ Deshape←IsArray◶{⟨𝕩⟩}‿⥊ Reshape←{ @@ -148,7 +158,7 @@ Reshape←{ s↩p⊣◶⊢‿a¨s {d∾↩(Fill d)⌜↕𝕩-n⋄n↩𝕩}⍟(n⊸<)⍟(3=t)lp×a } s - s⥊d(n<○(0⊸<)l)◶⟨Fill⊸(⊣¨)⋄{⊑⟜𝕨¨n|𝕩}⟩↕l + s⥊d(0<n)◶⟨<∘Fill⊸(⊣¨)⋄{⊑⟜𝕨¨n|𝕩}⟩↕l } Range←{ @@ -191,11 +201,11 @@ Depth←IsArray◶0‿{1+0⌈´Depth¨⥊𝕩} #⌜ # LAYER 4: Operators -> ↩ Merge ⊘ > +> ↩ Merge⍟IsArray ⊘ > ≍ ← >∘Pair ⎉ ← _rankOp_ ⚇ ← _depthOp_ -⍟ ← _repeat_ +⍟ ↩ _repeat_ ˘ ← ⎉¯1 ˝ ← _insert ` ← _scan @@ -208,7 +218,7 @@ Merge←(0<≠∘⥊)◶((∾○≢⥊⊢)⟜Fill)‿{ c←≢⊑𝕩 ! ∧´⥊(c≡≢)¨𝕩 𝕩⊑⟜ToArray˜⌜↕c -}⍟IsArray +} ValidateRanks←{ ! 1≥=𝕩 𝕩↩⥊𝕩 @@ -257,8 +267,10 @@ _repeat_←{ f←⊑𝕨⟨𝔽⟩⊘⟨𝕨𝔽⊢⟩𝕩 l←u←0 {!Int𝕩⋄l↩l⌊𝕩⋄u↩u⌈𝕩}⚇0 n - a←𝕩⋄_p←{𝔽∘⊣`(1+𝕩)⥊<a} - pos←F _p u ⋄ neg←F⁼_p-l + b←𝕨{𝕏⊣}˙⊘{𝕨˙{𝔽𝕏⊣}}0 + i←⟨𝕩⟩⋄P←B⊸{𝕎`i∾↕𝕩} + pos←𝕗 P u + neg←𝕗 0⊸<◶⟨i,{𝕏⁼}⊸P⟩ -l (|⊑<⟜0⊑pos‿neg˙)⚇0 n } @@ -18,7 +18,7 @@ pn ← init∾¨'0'∾¨post ⟨in,out⟩ ← GetReplacements ⟨⥊¨chr,pn⟩ # Make a new name for primitive 𝕩 -itr ← 0⥊˜≠chr +itr ← ¯1⥊˜≠chr Shadow ← { i←⊑chr⊐𝕩 n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr diff --git a/test/ref.bqn b/test/ref.bqn index e6cb40a5..50ad65f9 100644 --- a/test/ref.bqn +++ b/test/ref.bqn @@ -11,7 +11,7 @@ range ← {(≠⌜˜ ∧ nIsP ≤⎉1 ≥⌜˜ ∧ (NextSame𝕩)>⌜⊢) ↕≠ idChars ← "_¯.π∞𝕣"∾∾"0aA"+⟜↕¨10‿26‿26 defTok ← (¯1+`·¬·»⊸∧∊⟜idChars)⊸⊔¨ defs depend ← <∘/˘ range ∧ > (names∊LC¨)¨ (0=·+`·-˝"{"‿"}"≡⌜⊢)⊸/¨defTok -order ← {{𝕊⍟(𝕩<○≠⊢)⟜(𝕩∾·/𝕨⊸<)𝕨∨∧´∘⊏⟜𝕨¨l}⟜/0¨l←𝕩} depend +order ← {{(𝕨⊸∨𝕊⍟(𝕩<○≠⊢)𝕩∾/)(0»∨`)⊸<𝕨<∧´∘⊏⟜𝕨¨l}⟜/0¨l←𝕩} depend chrs←⟨ "+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!" @@ -21,7 +21,7 @@ chrs←⟨ def‿keep ← ⊑¨⌾(1⊸⊑) (1=≠)¨⊸⊔ anames keep∾↩"⌾" -pre←"IsArray←0<≡"‿"_amend←{𝕨˙⌾(𝕗⊸⊑)𝕩}"‿"Identity←{𝕏´⟨⟩}"‿"Fill←•FillFn" +pre←"Type←•Type"‿"_amend←{𝕨˙⌾(𝕗⊸⊑)𝕩}"‿"Identity←{𝕏´⟨⟩}"‿"Fill←•FillFn" GetRepls ← { ki ← (⊑¨⊑𝕩)∊keep |
