From d9c56581877376cb12c6b6c319fb4fc1714564c0 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 17 Feb 2021 16:33:36 -0500 Subject: Fix errors in reference function testing up to layer 3 --- spec/reference.bqn | 32 ++++++++++++++++++++++---------- src/pp.bqn | 2 +- 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 ↩ 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+𝕩)⥊⌜⊢) ↕≠ 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 -- cgit v1.2.3