429 lines
34 KiB
BQN
429 lines
34 KiB
BQN
%DEF var V←•internal.Variation ⋄ LV←•internal.ListVariations ⋄ CLR←•internal.ClearRefs
|
||
%DEF tvar %USE var ⋄ _tvar ← {F _𝕣 x: (CLR@) ⊢ {F 𝕩 V x}¨ LV 𝕩; w F _𝕣 x: (CLR@) ⊢ (LV 𝕨) {(𝕨 V w) F 𝕩 V x}⌜ LV 𝕩}
|
||
%DEF eqvar %USE tvar ⋄ _eqvar ← {r ← 𝕨 𝔽 _tvar 𝕩 ⋄ !∘≡⟜(⊑r)¨ r ⋄ ⊑r}
|
||
%DEF evar %USE tvar ⋄ _evar ← {ok←{⇐} ⋄ r←⥊𝕨 ok∘𝔽⎊{𝕊: •CurrentError@} _tvar 𝕩 ⋄ {⊑ok∊r? !"TEST FAIL: variation didn't error"; ("TEST FAIL: varying error messages"⊸⋈ ! 1=≠)⍷r ⋄ !⊑r}}
|
||
%DEF eqerr %USE eqvar ⋄ _eqerr ← {ok←{⇐} ⋄ r←⥊𝕨 ok∘𝔽⎊{𝕊: •CurrentError@}⌜ 𝕩 ⋄ {⊑ok∊r? !"TEST FAIL: case didn't error"; ("TEST FAIL: varying error messages"⊸⋈ ! 1=≠)⍷r ⋄ !⊑r}}
|
||
%DEF k _k ← {𝔽○•internal.Keep}
|
||
|
||
# batch checks
|
||
{>0‿1‿3‿'a'‿{⇐} (≠𝕏`)⎊'e'⌜ ⟨10⥊0, 10⥊10, 10⥊1e4, 10⥊1e9, 10⥊1e20, "AAA", "⍉⍉⍉", "𝕨𝕨𝕨"⟩}¨ ⌊‿⌈‿+‿≠‿< %% ⟨5‿8⥊10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e',5‿8⥊10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e',5‿8⥊10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿10‿10‿'e'‿'e'‿'e'‿10‿10‿10‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e',5‿8⥊10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3,5‿8⥊10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿10‿10‿10‿10‿10‿3‿3‿3‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'‿'e'⟩
|
||
|
||
# total array comparison
|
||
%USE k ⋄ a ← 0‿@‿'a'‿∞‿¯∞‿1‿¯1∾⍷∾{⟨𝕩⥊0, 𝕩⥊1, {1⌾((¯1¨≢𝕩)⊸⊑)𝕩}⍟(0≠×´∘≢) 𝕩⥊0⟩}¨ ∾{⥊(<⟨⟩)∾⌜´𝕩⥊<↕3}¨↕4 ⋄ r←(⊑(⍋-⍒)∘⋈)_k⌜˜ a ⋄ ! r ≡ •Cmp⌜˜a ⋄ r %% '1'-˜73‿73⥊"1000202002000002222000002000000222222222222200000200000022220000002000000210222222222222222222222222222222222222222222222222222222222222222222222222122222222222222222222222222222222222222222222222222222222222222222222222001222222222222222222222222222222222222222222222222222222222222222222222000010000200000222200000200000022222222222220000020000002222000000200000020002122022020222222020222022022222222222222202022202202222220220222022020000201002000002222000002000000222222222222200000200000022220000002000000200020210200000222200000200000022222222222220000020000002222000000200000020002222122020222222020222022022222222222222202022202202222220220222022020000000001000000000000000000000000000000000000000000000000000000000000000200020220210000222200000200000022222222222220000020000002222000000200000020002222222120222222020222022022222222222222202022202202222220220222022022000202202201002222200002202000222222222222220000220200022222020002202000200022222222212222222202222220222222222222222220222222022222222202222220220002022022020122222020022022022222222222222202002202202222220220222022020000000002000001000000000000000000000000000000000000000000000000000000000000000000200000210200000200000020020020020020000020000002002000000200000000000000020000022120000020000002202202202202000002000000220200000020000000000000002000002001000000000000200000000200000000000000020000000000000000200020220220000222210000200000022222222222220000020000002222000000200000020002222222220222222120222022022222222222222202022202202222220220222022022000202202202002222201002202000222222222222220000220200022222020002202000200022222222222222222212222220222222222222222220222222022222222202222220220002022022020222222020122022022222222222222202002202202222220220222022020000000002000002002000001000000200200000200200000000000020020000000000000200020220220000222220000210000022222222222222000020000002222202000200000020002222222220222222220222122022222222222222222022202202222222220222022022000202202200002222200002201000222222222222220000220000022222020002202000200020220220200222220200220210022222222222222020022020002222202202220200020002222222222222222222222222122222222222222222222222202222222222222222022000202202202002222202002202201222222222222220200220220022222022022202202000000000200000200000000000000010000000000000000000000000000000000000000000000000020000022020000020000002102002002002000002000000200200000020000000000000002000002222000002000000221220220220200000200000022020000002000000000000000200000200200000000000020010000020000000000000002000000000000000000000000020000022020000020000002202102002202000002000000220200000020000000000000002000002222000002000000222221220222200000200000022220000002000000000000000200000200200000200000020020010020020000000000002002000000000000000000000020000022020000020000002202202102202000002000000220200000020000000000000002000002222000002000000222222221222200000200000022220000002000000000000000200000200000000000000020000000010000000000000000000000000000000000000000020000022020000020000002202002002102000002000000200200000020000000000000002000002222000002000000222220220221200000200000022020000002000000000000000200000200200000000000020020000020010000000000002000000000000000020002022022000022222000020000002222222222222100002000000222200000020000002000222222222022222222022202202222222222222221202220220222222022022202202200020220220200222220200220200022222222222222010022020002222202000220200020002222222222222222222222222022222222222222222122222202222222220222222022000202202202022222202022202202222222222222220201220220222222022022202202000000000200000200200000200000020020020020020000010000002002000000000000020002022022000022222000022000002222222222222200002100000222220200020000002000222222222022222222022222202222222222222222202221220222222222022202202200020220220000222220000220200022222222222222000022010002222202000220200020002022022020022222020022022002222222222222202002202100222220220222020002000222222222222222222222222222222222222222222222222221222222222222222202200020220220200222220200220220222222222222222020022022012222202202220220200000000020000020000000000000002000000002000000000000000100000000000000000000000002000002202000002000000220200200220200000200000021020000002000000000000000200000222200000200000022222022022220000020000002212000000200000000000000020000020020000000000002002000002002000000000000200100000000000002000202202200002222200002000000222222222222220000200000022221000002000000200022222222202222222202220220222222222222222220222022022222212202220220220002022022000022222000020000002222222222222200002000000222220100020000002000202202202002222202002202000222222222222220200220200022222021002202000200022222222222222222222222220222222222222222222222222022222222212222220220002022022020022222020022020002222222222222202002202000222220220122020000000000002000002002000002000000200200200200200000200000020020000001000000200020220220000222220000220000022222222222222000022000002222202000210000020002222222220222222220222222022222222222222222022222202222222220222122022000202202200002222200002200000222222222222220000220000022222020002201000200020220220200222220200220220022222222222222020022022002222202202220210020002222222222222222222222222222222222222222222222222222222222222222222122000202202202002222202002202200222222222222220200220220022222022022202201"
|
||
!"∧: Argument cannot have rank 0" % ∧@
|
||
!"∨: Argument cannot have rank 0" % ∨@
|
||
(=⋈≡)˜{⇐} %% 1‿1
|
||
(≠⋈≢)˜{⇐} %% 0‿0
|
||
{⇐}(=⋈≡){⇐} %% 0‿0
|
||
{⇐}(≠⋈≢){⇐} %% 1‿1
|
||
|
||
# !𝕩 & 𝕨!𝕩
|
||
!"Assertion error" % !0
|
||
!"Assertion error" % !0
|
||
!"foo" % !"foo"
|
||
!"foo" % "foo"!0
|
||
!"foo" % "foo"!"bar"
|
||
!⎊•CurrentError 1‿+ %% ⟨1,+⟩
|
||
!⟜0⎊•CurrentError 1‿+ %% ⟨1,+⟩
|
||
!1 %% 1
|
||
"foo"!1 %% 1
|
||
|
||
|
||
# |𝕩
|
||
{| (↕10)∾𝕩}¨ -2⋆7‿15‿31 %% ⟨0‿1‿2‿3‿4‿5‿6‿7‿8‿9‿128,0‿1‿2‿3‿4‿5‿6‿7‿8‿9‿32768,0‿1‿2‿3‿4‿5‿6‿7‿8‿9‿2147483648⟩
|
||
|
||
# arith
|
||
(<1)+ 1 %% <2
|
||
1 +<1 %% <2
|
||
(<1)+<1 %% <2
|
||
@-@ %% 0
|
||
!"-: Invalid character" % @-1
|
||
{r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ @ 0∘𝕏⎊{𝕊: •CurrentError@} @}¨ ⟨+, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
{r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ 0 0∘𝕏⎊{𝕊: •CurrentError@} @}¨ ⟨ -, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
{r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ @ 0∘𝕏⎊{𝕊: •CurrentError@} 0}¨ ⟨ ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
|
||
%USE var ⋄ a←4⥊@ ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ @ 0∘𝕏⎊{𝕊: •CurrentError@} 𝕨 V a}⌜ ⟨+, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊@ ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ 0 0∘𝕏⎊{𝕊: •CurrentError@} 𝕨 V a}⌜ ⟨ -, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊0 ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ @ 0∘𝕏⎊{𝕊: •CurrentError@} 𝕨 V a}⌜ ⟨ ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
|
||
%USE var ⋄ a←4⥊@ ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘𝕏⎊{𝕊: •CurrentError@} @}⌜ ⟨+, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊0 ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘𝕏⎊{𝕊: •CurrentError@} @}⌜ ⟨ -, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊@ ⋄ (LV a) {r←•Repr𝕩 ⋄ (⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘𝕏⎊{𝕊: •CurrentError@} 0}⌜ ⟨ ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
|
||
%USE var ⋄ a←4⥊@ ⋄ b←4⥊@ ⋄ {r←•Repr f←𝕩 ⋄ {(⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘F⎊{𝕊: •CurrentError@} 𝕩 V b}⌜○LV´ a‿b}⌜ ⟨+, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊0 ⋄ b←4⥊@ ⋄ {r←•Repr f←𝕩 ⋄ {(⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘F⎊{𝕊: •CurrentError@} 𝕩 V b}⌜○LV´ a‿b}⌜ ⟨ -, ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
%USE var ⋄ a←4⥊@ ⋄ b←4⥊0 ⋄ {r←•Repr f←𝕩 ⋄ {(⊢!≡´) (r∾": Unexpected argument types") ⋈ (𝕨 V a) 0∘F⎊{𝕊: •CurrentError@} 𝕩 V b}⌜○LV´ a‿b}⌜ ⟨ ×, ÷, ⋆, √, ⌊, ⌈, |, ∧, ∨, ÷⟩
|
||
|
||
!"-: Unexpected argument types" % 0-@
|
||
!"÷: Unexpected argument types" % 0÷@
|
||
!"+: Argument must consist of numbers" % +@
|
||
⟨@, "abc", ⟨1,2,+⟩, {⇐}⟩ {(⊢!≡´) (": Argument contained non-number"∾˜•Repr 𝕩) ⋈ 0∘𝕏⎊{𝕊: •CurrentError@} 𝕨}⌜ -‿×‿÷‿⋆‿√‿⌊‿⌈‿|‿¬
|
||
!"This function can't be called monadically" % ≤@
|
||
!"This function can't be called monadically" % ≥@
|
||
|
||
# 𝕨/𝕩
|
||
2‿3‿0‿1/4‿3⥊↕⋈12 %% ⋈¨6‿3⥊0‿1‿2‿0‿1‿2‿3‿4‿5‿3‿4‿5‿3‿4‿5‿9‿10‿11
|
||
2‿3‿0‿1/↕4 %% 6⥊0‿0‿1‿1‿1‿3
|
||
2‿3‿0‿1/↕⋈4 %% ⋈¨6⥊0‿0‿1‿1‿1‿3
|
||
!"Expected non-negative integer, got ¯3" % 2‿¯3/↕2
|
||
!"Expected non-negative integer, got ¯3e20" % 2‿¯3e20/↕2
|
||
!"/: Lengths of components of 𝕨 must match 𝕩 (3 ≠ 4)" % 1‿2‿3/4‿5‿6‿7
|
||
!"Expected non-negative integer, got ¯1000" % (4/1000‿¯1000) / 8⥊1
|
||
!"Expected non-negative integer, got ¯1000" % (4/1000‿¯1000) / 8⥊1
|
||
!"Integer out of range: 4e19" % %USE evar ⋄ 2‿4e19 /_evar ↕2
|
||
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % ⟨↕1⟩/3
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % ⟨↕1⟩/<"ab"
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % (<↕1)/<"ab"
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % (<↕0)/<"ab"
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % ⟨↕10,↕10⟩ / 10⥊10
|
||
!"𝕨/𝕩: Length of compound 𝕨 must be at most rank of 𝕩" % ⟨↕10,↕10,<0⟩ / 10‿10⥊10
|
||
!"/: Simple 𝕨 must have rank 0 or 1 (2≡=𝕨)" % (2‿1⥊↕4) / 4‿4⥊↕16
|
||
!"𝕨/𝕩: Compound 𝕨 must have rank at most 1" % (2‿1⥊<↕4) / 4‿4⥊↕16
|
||
!"/: Simple 𝕨 must have rank 0 or 1 (2≡=𝕨)" % (1‿2⥊↕4) / ↕4
|
||
!"𝕨/𝕩: Compound 𝕨 must have rank at most 1" % (1‿2⥊<↕4) / ↕4
|
||
!"𝕨/𝕩: 𝕨 must consist of natural numbers" % ⟨↕4, 1‿2‿3.5‿4⟩ / 4‿4⥊↕16
|
||
!"𝕨/𝕩: 𝕨 must consist of natural numbers" % ⟨↕4, 3.5⟩ / 4‿4⥊↕16
|
||
!"Integer out of range: 4.611686018427388e18" % ⟨1,2⋆62⟩ / 2‿2⥊<⋈0
|
||
!"Integer out of range: 4.611686018427388e18" % ⟨1,2⋆62⟩ / 2⥊<⋈0
|
||
⟨↕4, 0, ↕5⟩ / 4‿4‿5⥊@ %% 6‿0‿10⥊@
|
||
⟨↕4, 4⥊0, ↕5⟩ / 4‿4‿5⥊@ %% 6‿0‿10⥊@
|
||
1‿0‿2 / ⋈¨ ["ab","cd","ef"] %% ⋈¨ ["ab","ef","ef"]
|
||
(<1‿0‿2) / ⋈¨ ["ab","cd","ef"] %% ⋈¨ ["ab","ef","ef"]
|
||
(⋈1‿0‿2) / ⋈¨ ["ab","cd","ef"] %% ⋈¨ ["ab","ef","ef"]
|
||
1‿0‿0/3‿0‿2⥊0 %% 1‿0‿2⥊0
|
||
1‿0‿0/3‿0‿2⥊'a' %% 1‿0‿2⥊' '
|
||
1‿0‿0/3‿0‿2⥊<"a" %% 1‿0‿2⥊<" "
|
||
(10000⥊1‿0)/10000‿0‿2⥊0 %% 5000‿0‿2⥊0
|
||
|
||
# /𝕩
|
||
!"Expected non-negative integer, got ¯1000" % / 4/1000‿¯1000
|
||
!"/: Argument must have rank 1 (3‿3 ≡ ≢𝕩)" % /↕3‿3
|
||
!"/: Argument must have rank 1 (⟨⟩ ≡ ≢𝕩)" % /0
|
||
!"Expected non-negative integer, got ¯1" % %USE evar ⋄ /_evar ¯1⌾(100⊸⊑) 200⥊10
|
||
!"Sum too big" % %USE evar ⋄ /_evar 1e2⥊2⋆62
|
||
!"Integer out of range: 1e20" % %USE evar ⋄ /_evar 1e20⌾(100⊸⊑) 200⥊10
|
||
! (//⁼)⊸≡8‿15‿25‿32‿90‿101‿155‿165‿584‿594‿894‿912‿1312‿1328‿1350‿1367‿1391‿1407‿1469‿1486‿1559‿1566‿1576‿1582‿1592‿1599‿1609‿1616‿1626‿1635‿4086‿4093‿4114‿4122‿4141‿4149‿4169‿4177
|
||
|
||
# 𝕨⊏𝕩
|
||
•internal.ElType¨ {(100⥊↕2)⊏𝕨‿𝕩}⌜˜ ⟨0, 1, 2, 127, 128, 32767, 32768, ¯32767, ¯32768, ¯32769, ¯1+2⋆31, 2⋆31, @, @+1, @+255, @+256, @+1114111, {⇐}, 1‿2⟩ %% (8-(=⌜˜<⟜5)×8-⌈⌜˜) 0‿0‿1‿1‿2‿2‿3‿2‿2‿3‿3‿4‿5‿5‿5‿6‿7‿8‿8
|
||
0‿0‿0 ⊏ 1‿3⥊↕10 %% 3‿3⥊0‿1‿2
|
||
≢¨ ⟨(2‿0‿3‿4‿5⥊1)⊏9‿8‿0‿7⥊0 ⋄ ⟨⟩⊏0‿8‿0‿7⥊0 ⋄ (2‿3‿0‿4⥊1)⊏↕10⟩ %% ⟨2‿0‿3‿4‿5‿8‿0‿7,0‿8‿0‿7,2‿3‿0‿4⟩
|
||
!"⊏: Indexing out-of-bounds (1∊𝕨, 1≡≠𝕩)" % ⊏˜(200⥊1)⥊1
|
||
!"⊏: Indexing out-of-bounds (24∊𝕨, 4≡≠𝕩)" % %USE evar ⋄ 1‿24 ⊏_evar ↕4‿4
|
||
!"⊏: Indexing out-of-bounds (¯24∊𝕨, 4≡≠𝕩)" % %USE evar ⋄ 1‿¯24 ⊏_evar ↕4‿4
|
||
!"𝕨⊏𝕩: 𝕨 must be an array of numbers or list of such arrays" % %USE evar ⋄ (1‿¯26∾@) ⊏_evar @∾↕5
|
||
!"⊏: Indexing out-of-bounds (¯26∊𝕨, 5≡≠𝕩)" % %USE evar ⋄ ¯26⊸⊏_evar ↕5
|
||
!"Expected integer, got ¯26.5" % %USE evar ⋄ ¯26.5⊸⊏_evar ↕5
|
||
!"⊏: Indexing out-of-bounds (¯26∊𝕨, 5≡≠𝕩)" % %USE evar ⋄ 1‿¯26 ⊏_evar ↕5
|
||
!"⊏: Indexing out-of-bounds (26∊𝕨, 5≡≠𝕩)" % %USE evar ⋄ 1‿26 ⊏_evar ↕5
|
||
!"Expected integer, got 1.1" % %USE evar ⋄ 0‿1.1‿2 ⊏_evar ↕10
|
||
!"⊏: Indexing out-of-bounds (1∊𝕨, 1≡≠𝕩)" % %USE evar ⋄ 0‿0‿1 ⊏_evar 1‿3⥊↕10000
|
||
!"⊏: Indexing out-of-bounds (2∊𝕨, 2≡≠𝕩)" % %USE evar ⋄ (1+9=↕10) ⊏_evar ⟨1‿2,3⟩
|
||
!"⊏: Indexing out-of-bounds (4∊𝕨, 3≡≠𝕩)" % %USE evar ⋄ 1‿4‿2‿0‿10‿5‿6 ⊏_evar 1‿0‿1
|
||
!"⊏: Indexing out-of-bounds (¯4∊𝕨, 3≡≠𝕩)" % %USE evar ⋄ (-1‿4‿2‿0‿10‿5‿6) ⊏_evar 1‿0‿1
|
||
!"⊏: Indexing out-of-bounds (4000∊𝕨, 1001≡≠𝕩)" % %USE evar ⋄ ( 1000×1‿4‿2‿0‿10‿5‿6) ⊏_evar 1001⥊1‿0‿1
|
||
!"⊏: Indexing out-of-bounds (¯4000∊𝕨, 1001≡≠𝕩)" % %USE evar ⋄ (¯1000×1‿4‿2‿0‿10‿5‿6) ⊏_evar 1001⥊1‿0‿1
|
||
%USE tvar ⋄ !∘≡¨⟜⊏ ∾ {⥊𝕨 ⊏⎊(•CurrentError∘⊢) _tvar 𝕩}´¨ ⟨⟨0‿1, ⋈0⟩ ⋄ ⟨0‿1, "?"⟩ ⋄ ⟨0‿1, ≍0‿1⟩⟩
|
||
a←↕2 ⋄ ! "e" ≡ (↕10){b←a‿a‿a‿a‿a‿a‿a‿a‿a‿a ⋄ 𝕨⊏⎊"e"𝕩}⟨1‿2,3‿4⟩ ⋄ ! 0‿1 ≡ a
|
||
%USE eqvar ⋄ {1‿¯1 {r←𝕨⊏𝕩 ⋄ ! 𝕩 ≥○•internal.ElType r ⋄ r}_eqvar 𝕩}¨ ⟨↕2, ↕4, "hello", ⟨"ab", "cd", "ef"⟩, ↕⋈4⟩
|
||
!"⊏: 𝕩 cannot be a unit" % 0⊏<"a"
|
||
!"⊏: 𝕩 cannot be a unit" % 0⊏<5
|
||
!"⊏: 𝕩 cannot be an atom" % 0⊏5
|
||
!"⊏: 𝕩 cannot be a unit" % ⟨⟩⊏<"a"
|
||
!"⊏: 𝕩 cannot be a unit" % ⟨⟩⊏<5
|
||
!"⊏: 𝕩 cannot be an atom" % ⟨⟩⊏5
|
||
!"Expected integer, got 1.5" % ⟨1.5⟩ ⊏ "ab"‿"cd"
|
||
!"⊏: Indexing out-of-bounds (10∊𝕨, 2≡≠𝕩)" % ⟨10⟩ ⊏ "ab"‿"cd"
|
||
{𝕩 ! ↕∘≠⊸⊏⊸≡ 20‿𝕩•rand.Range 2}¨ (↕70)∾⥊(64×1‿2‿3‿4‿5)+⌜¯1‿0‿1‿30‿60
|
||
|
||
# 𝕨⊑𝕩
|
||
!"⊑: 𝕨 contained a non-integer" % ⟨0.1⟩⊑↕3
|
||
!"⊑: 𝕨 contained a non-integer" % ⟨2⋆80⟩⊑↕3
|
||
!"⊑: Leaf arrays in 𝕨 must have rank 1 (element: (1‿2⥊1‿2))" % %USE evar ⋄ (≍1‿2) {⟨𝕨⟩⊑𝕩}_evar ↕5‿5
|
||
%USE eqvar ⋄ 1‿2 ⊑_eqvar ↕5‿5 %% 1‿2
|
||
|
||
# comparison
|
||
w←1‿1⥊1 ⋄ x←1‿2⥊1 ⋄ {! (∾⟨•Repr𝕩,": Expected equal shape prefix (1‿1 ≡ ≢𝕨, 1‿2 ≡ ≢𝕩)"⟩) ≡ w 𝕏⎊(•CurrentError∘@) x}¨ =‿≠‿<‿>‿≤‿≥
|
||
w←1‿1⥊1 ⋄ x←1‿2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨•Repr𝕩,": Expected equal shape prefix (1‿1 ≡ ≢𝕨, 1‿2 ≡ ≢𝕩)"⟩) ≡ w 𝕏⎊(•CurrentError∘@) x}¨ =‿≠‿<‿>‿≤‿≥
|
||
w←1‿1⥊1 ⋄ x←2⥊1 ⋄ {! (∾⟨•Repr𝕩,": Expected equal shape prefix (1‿1 ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)"⟩) ≡ w 𝕏⎊(•CurrentError∘@) x}¨ =‿≠‿<‿>‿≤‿≥
|
||
w←1‿1⥊1 ⋄ x←2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨•Repr𝕩,": Expected equal shape prefix (1‿1 ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)"⟩) ≡ w 𝕏⎊(•CurrentError∘@) x}¨ =‿≠‿<‿>‿≤‿≥
|
||
!"Invalid comparison" % <˜{⇐}
|
||
!"Invalid comparison" % ≤˜{⇐}
|
||
!"Invalid comparison" % >˜{⇐}
|
||
!"Invalid comparison" % ≥˜{⇐}
|
||
{! 5 (𝕏 ≡ 𝕏⌾⋈) ↕10}¨ =‿≠‿<‿>‿≤‿≥
|
||
{! (↕10) (𝕏 ≡ 𝕏⌾⋈) 5}¨ =‿≠‿<‿>‿≤‿≥
|
||
{! (↕10) (𝕏 ≡ 𝕏⌾⋈) 4⌊↕10}¨ =‿≠‿<‿>‿≤‿≥
|
||
|
||
# >𝕩
|
||
!">: Result rank too large (200 ≡ =𝕩, 205 ≡ =⊑𝕩)" % > (200⥊1)⥊<(205⥊1)⥊1
|
||
!">: Incompatible element shapes (encountered shapes ⟨2⟩ and 4‿5)" % > ↕¨⟨2, 4‿5⟩
|
||
!">: Incompatible element shapes (encountered shapes 2‿3 and ⟨4⟩)" % > ↕¨⟨2‿3, 4⟩
|
||
!">: Incompatible element shapes (encountered shapes 2‿3 and 4‿5)" % > ↕¨⟨2‿3, 4‿5⟩
|
||
!">: Incompatible element shapes (encountered shapes 2‿0 and 4‿5)" % > ↕¨⟨2‿0, 4‿5⟩
|
||
!">: Incompatible element shapes (encountered shapes ⟨0⟩ and 4‿5)" % > ↕¨⟨0, 4‿5⟩
|
||
!">: Incompatible element shapes (encountered shapes ⟨0⟩ and ⟨⟩)" % > ↕¨⟨0, ⟨⟩⟩
|
||
!">: Incompatible element shapes (encountered shapes 2‿3 and ⟨⟩)" % > ↕¨⟨2‿3, ⟨⟩⟩
|
||
!">: Incompatible element shapes (encountered shapes 4‿5 and 4‿6)" % ≢>2‿3⥊⟨4‿5⥊↕20,4‿6⥊↕1⟩
|
||
!"∾: Item trailing shapes must be equal (contained arrays with shapes ⟨2⟩ and ⟨3⟩ and later higher-rank array)" % ∾⟨1‿1, 1‿1‿1, ⟨1⟩, 2‿2⥊1⟩
|
||
!"∾: Item trailing shapes must be equal (contained arrays with shapes 1‿4 and ⟨0⟩)" % ∾⟨1‿4⥊"abcd",⟨⟩⟩
|
||
>⟨<'a',1⟩ %% 'a'‿1
|
||
>⟨1,2,<3,4,<<5⟩ %% ⟨1,2,3,4,<5⟩
|
||
≢>0‿1⥊<2‿3⥊<"ab" %% ↕4
|
||
{a←↕3 ⋄ !'e'≡>⎊'e' ⟨a, a, ↕2, a, a⟩ ⋄ ! 1≡•internal.Refc a}
|
||
{a←↕3 ⋄ > ⟨a, a, ↕3, a, a⟩ ⋄ ! 1≡•internal.Refc a}
|
||
{a←(200⥊1)⥊↕3 ⋄ ! 'e'≡>⎊'e' (200⥊1)⥊⟨a, a, ↕2, a, a⟩ ⋄ ! 1≡•internal.Refc a}
|
||
%USE var ⋄ a←2‿3⥊↕6 ⋄ b←2‿3⥊"abcdef" ⋄ !∘≡¨⟜⊏ ⥊ (LV a) {>1‿2‿1‿1⥊𝕨‿𝕩V¨a‿b}⌜ LV b
|
||
%USE var ⋄ a←b←2‿3⥊<<˘"abcd" ⋄ !∘≡¨⟜⊏ ⥊ (LV a) {>1‿2‿1‿1⥊𝕨‿𝕩V¨a‿b}⌜ LV b
|
||
%USE var ⋄ {a‿b: ! ∧´(⊏≡¨⊢)⥊ (LV a) {>1‿2‿1‿1⥊𝕨‿𝕩V¨a‿b}⌜ LV b}¨ ⟨2⥊<2‿3⥊<<˘"abcd" ⋄ ⟨2‿3⥊↕6,2‿3⥊"abcdef"⟩⟩
|
||
%USE var ⋄ {a‿b: ! ∧´(⊏≡¨⊢)⥊ (LV a) {∾𝕨‿𝕩V¨a‿b}⌜ LV b}¨ ⟨2⥊<2‿3⥊<<˘"abcd" ⋄ ⟨2‿3⥊↕6,2‿3⥊"abcdef"⟩⟩
|
||
|
||
# <𝕩
|
||
! ⊑∘<¨⊸≡ ∾⟜- ⥊(¯2+↕5)+⌜2⋆↕40
|
||
! ⊑∘<¨⊸≡ @+⥊¯1‿0‿1+⌜2⋆↕20
|
||
! ⊑∘<⊸≡ {⇐}
|
||
|
||
# ⋈𝕩
|
||
! ⊑∘⋈¨⊸≡ ∾⟜- ⥊(¯2+↕5)+⌜2⋆↕40
|
||
! ⊑∘⋈¨⊸≡ @+⥊¯1‿0‿1+⌜2⋆↕20
|
||
! ⊑∘⋈⊸≡ {⇐}
|
||
|
||
# ∾𝕩
|
||
∾⟨"ab", 12, "de"⟩ %% ⟨'a','b',12,'d','e'⟩
|
||
!"∾: Item trailing shapes must be equal (contained arrays with shapes 3‿3 and 3‿4)" % ∾⟨↕3‿3,↕3‿4⟩
|
||
!"∾: Item trailing shapes must be equal (contained arrays with shapes ⟨2⟩ and 3‿3)" % ∾⟨1‿2,↕3‿3⟩
|
||
!"∾: Item ranks along an axis can differ by at most one (contained ranks 1 and 3 along axis 0)" % ∾2‿1 ⥊ ⥊⟜0¨ ⟨0‿2‿3, 0⟩
|
||
!"∾: Incompatible item shapes (contained arrays with shapes 1‿0 and 1‿0 along axis 1)" % ∾ {1‿𝕩⥊0}¨ [0‿1, 0‿0]
|
||
!"∾: Incompatible item ranks" % ∾ ⥊⟜0¨ [0‿1⋈0‿1, 0‿1⋈1]
|
||
∾3‿3⥊<1‿0‿3⥊0 %% 3‿0‿3⥊0
|
||
∾3‿3⥊<0‿0⥊⟨⟩ %% 0‿0⥊⟨⟩
|
||
⊑1↑⥊∾3‿3⥊<1‿0‿3⥊<"hi" %% " "
|
||
|
||
# 𝕨∾𝕩
|
||
!"∾: Lengths not matchable (⟨6⟩ ≡ ≢𝕨, 1‿1 ≡ ≢𝕩)" % ("abc"∾"def")∾≍"a"
|
||
!"∾: Lengths not matchable (⟨6⟩ ≡ ≢𝕨, 1‿1 ≡ ≢𝕩)" % (("abc")∾"def")∾1‿1⥊1
|
||
|
||
! (∘‿2⥊"abcdefgh") ≡ ["ab","cd"]∾["ef","gh"]
|
||
! (∘‿2⥊"abcdef") ≡ ["ab","cd"]∾"ef"
|
||
! (∘‿2⥊"abcdef") ≡ "ab"∾["cd","ef"]
|
||
! (∘‿2⥊"abcdefgh") ≡ (a←["ab","cd"])∾["ef","gh"] ⋄ •internal.Keep a
|
||
! (∘‿2⥊"abcdef") ≡ (a←["ab","cd"])∾"ef" ⋄ •internal.Keep a
|
||
! (∘‿2⥊"abcdef") ≡ "ab"∾a←["cd","ef"] ⋄ •internal.Keep a
|
||
|
||
!"∾: Argument ranks must differ by 1 or less (0≡=𝕨, 2≡=𝕩)" % 1∾↕3‿3
|
||
!"∾: Argument ranks must differ by 1 or less (1≡=𝕨, 3≡=𝕩)" % 1‿2∾↕3‿3‿3
|
||
!"∾: Argument ranks must differ by 1 or less (3≡=𝕨, 1≡=𝕩)" % 1‿2∾˜↕3‿3‿3
|
||
!"∾: Lengths not matchable (3‿4 ≡ ≢𝕨, 3‿3 ≡ ≢𝕩)" % (↕3‿4)∾↕3‿3
|
||
|
||
!"∾: Lengths not matchable (2‿2 ≡ ≢𝕨, 2‿3 ≡ ≢𝕩)" % ["ab","cd"]∾["efg","hjk"]
|
||
!"∾: Lengths not matchable (2‿2 ≡ ≢𝕨, ⟨3⟩ ≡ ≢𝕩)" % ["ab","cd"]∾"efg"
|
||
!"∾: Lengths not matchable (⟨3⟩ ≡ ≢𝕨, 2‿2 ≡ ≢𝕩)" % "abz"∾["cd","ef"]
|
||
!"∾: Lengths not matchable (2‿2 ≡ ≢𝕨, 2‿3 ≡ ≢𝕩)" % (a←["ab","cd"])∾["efg","hjk"]
|
||
!"∾: Lengths not matchable (2‿2 ≡ ≢𝕨, ⟨3⟩ ≡ ≢𝕩)" % (a←["ab","cd"])∾"efg"
|
||
!"∾: Lengths not matchable (⟨3⟩ ≡ ≢𝕨, 2‿2 ≡ ≢𝕩)" % "abz"∾a←["cd","ef"]
|
||
|
||
# 𝕨≍𝕩
|
||
!"≍: 𝕨 and 𝕩 must have equal shapes (3‿4 ≡ ≢𝕨, 3‿3 ≡ ≢𝕩)" % (↕3‿4)≍↕3‿3
|
||
!"≍: 𝕨 and 𝕩 must have equal shapes (⟨3⟩ ≡ ≢𝕨, ⟨2⟩ ≡ ≢𝕩)" % 1‿2‿3≍1‿2
|
||
!"≍: 𝕨 and 𝕩 must have equal shapes (⟨3⟩ ≡ ≢𝕨, ⟨⟩ ≡ ≢𝕩)" % 1‿2‿3≍1
|
||
!"≍: Result rank too large" % ≍˜(255⥊1)⥊1
|
||
|
||
# ≍𝕩
|
||
!"≍: Result rank too large (255≡=𝕩)" % ≍⍟256 1
|
||
%USE eqvar ⋄ 1‿2‿3‿4‿5‿64 {c𝕊e: ∾_eqvar´¨ ⟨4‿c, c⟩ ⋈⌜○({𝕩⥊<e}¨) ⟨0‿c, 1‿c, c⟩}⌜ ⟨1, 'a', 1‿2⟩
|
||
|
||
# « & »
|
||
!"shift: Lengths not matchable (⟨2⟩ ≡ ≢𝕨, 3‿3 ≡ ≢𝕩)" % 1‿2»↕3‿3
|
||
!"shift: =𝕨 must be =𝕩 or ¯1+=𝕩 (0≡=𝕨, 3≡=𝕩)" % 1»↕2‿2‿2
|
||
!"shift: =𝕨 must be =𝕩 or ¯1+=𝕩 (2≡=𝕨, 1≡=𝕩)" % (↕2‿2)»1‿2
|
||
!"shift: Lengths not matchable (⟨2⟩ ≡ ≢𝕨, 3‿3 ≡ ≢𝕩)" % 1‿2«↕3‿3
|
||
!"shift: =𝕨 must be =𝕩 or ¯1+=𝕩 (0≡=𝕨, 3≡=𝕩)" % 1«↕2‿2‿2
|
||
!"shift: =𝕨 must be =𝕩 or ¯1+=𝕩 (2≡=𝕨, 1≡=𝕩)" % (↕2‿2)«1‿2
|
||
!"«: Argument cannot be a scalar" % «0
|
||
!"»: Argument cannot be a scalar" % »<0
|
||
|
||
# ⍉𝕩
|
||
%USE var ⋄ !∘≡¨⟜⊏ {⍉ 𝕩 V a}¨ LV a←2‿3‿4•rand.Range 2
|
||
%USE var ⋄ !∘≡¨⟜⊏ {⍉ 𝕩 V a}¨ LV a←⋈¨ 2‿3‿4•rand.Range 2
|
||
%USE var ⋄ !∘≡¨⟜⊏ {⍉ 𝕩 V a}¨ LV a←@+2‿3‿4•rand.Range 100
|
||
|
||
# ⌽𝕩
|
||
%USE var ⋄ {{! 𝕩 ≡ ⌽"Ai8"V⌽𝕩} 𝕩•rand.Range 2}¨ ↕1000
|
||
|
||
# 𝕨⌽𝕩
|
||
!"Integer out of range: 1e20" % %USE eqerr ⋄ ⟨1e20,⟨1e20⟩⟩ ⌽_eqerr ⟨↕10, ↕0, 0‿0⥊0, ⟨⟩⟩
|
||
!"Expected integer, got NaN" % %USE eqerr ⋄ ⟨0÷0, ⟨0÷0⟩⟩ ⌽_eqerr ⟨↕10, ↕0, 0‿0⥊0, ⟨⟩⟩
|
||
!"Integer out of range: ∞" % %USE eqerr ⋄ ⟨∞, ⟨∞⟩⟩ ⌽_eqerr ⟨↕10, ↕0, 0‿0⥊0, ⟨⟩⟩
|
||
!"Expected integer, got function" % %USE eqerr ⋄ ⟨⊑ ⟩ ⌽_eqerr ⟨↕10, ↕0, 0‿0⥊0, ⟨⟩⟩
|
||
!"Expected integer, got character" % %USE eqerr ⋄ ⟨'a'⟩ ⌽_eqerr ⟨↕10, ↕0, 0‿0⥊0, ⟨⟩⟩
|
||
!"⌽: 𝕨 contained non-number" % %USE eqerr ⋄ ⟨3‿'a', 'a'‿3, 0‿'a', 'a'‿0⟩ ⌽_eqerr ⟨0‿0⥊0,0‿0‿0⥊0⟩
|
||
!"Integer out of range: ∞" % %USE eqerr ⋄ ⟨3‿∞, ∞‿3, 0‿∞, ∞‿0⟩ ⌽_eqerr ⟨0‿0⥊0,0‿0‿0⥊0⟩
|
||
(1+1e15) ⌽ ↕10 %% (1+↕9)∾0
|
||
(-1+1e15) ⌽ ↕10 %% 9∾↕9
|
||
|
||
# ↑𝕩 & ↓𝕩
|
||
!"↑: Argument must have rank at least 1" % ↑0
|
||
!"↓: Argument must have rank at least 1" % ↓<0
|
||
|
||
# 𝕨↓𝕩 & 𝕨↑𝕩
|
||
≠⍷•Hash¨ ⟨¯1↓•internal.Squeeze 1e9∾˜↕10000, ↕10000⟩ %% 1
|
||
≠⍷•Hash¨ ⟨10000↑•internal.Squeeze 1e9∾˜↕10000, ↕10000⟩ %% 1
|
||
|
||
# ¨
|
||
1 {𝕊:1‿2}¨ 1 %% <1‿2
|
||
1 {𝕊:1‿2}¨<1 %% <1‿2
|
||
(<1){𝕊:1‿2}¨ 1 %% <1‿2
|
||
(<1){𝕊:1‿2}¨<1 %% <1‿2
|
||
1 1‿2¨ 1 %% <1‿2
|
||
1 1‿2¨<1 %% <1‿2
|
||
(<1)1‿2¨ 1 %% <1‿2
|
||
(<1)1‿2¨<1 %% <1‿2
|
||
!"Mapping: Expected equal shape prefix (⟨2⟩ ≡ ≢𝕨, 4‿4 ≡ ≢𝕩)" % 1‿2+¨↕4‿4
|
||
!"Mapping: Expected equal shape prefix (⟨2⟩ ≡ ≢𝕨, ⟨4⟩ ≡ ≢𝕩)" % 1‿2+¨↕4
|
||
⊢¨ {a←𝕩 ⋄ ⥊𝕩} 2‿3⥊<"a" %% 6⥊<"a"
|
||
⊢¨ {a←𝕩 ⋄ 2‿3‿1⥊𝕩} 2‿3⥊<"a" %% 2‿3‿1⥊<"a"
|
||
⊢¨ {a←𝕩 ⋄ 2‿3‿1⥊𝕩} 6⥊<"a" %% 2‿3‿1⥊<"a"
|
||
⊢¨ {a←𝕩 ⋄ 2‿3⥊⥊𝕩} 2‿3⥊<"a" %% 2‿3⥊<"a"
|
||
⊢¨ 2‿3⥊<"a" %% 2‿3⥊<"a"
|
||
%USE tvar ⋄ {•Repr∘𝕩⍟¬⊸! (⊢¨ ≡○(10⊸↑) •internal.PureKeep¨) 𝕩}_tvar¨ ⟨⊔↕2, ⊔↕0, ↕5, ↕0, "hello", ""⟩
|
||
|
||
# ⊔
|
||
!"⊔: ≠𝕨 must be either ≠𝕩 or one bigger (2≡≠𝕨, 3≡≠𝕩)" % 0‿0⊔↕3
|
||
!"Out of memory" % ⟨∞⟩⊔"a"
|
||
!"Out of memory" % ⟨1e50⟩⊔"a"
|
||
|
||
# ↕𝕩
|
||
!"Expected non-negative integer, got character" % ↕@
|
||
!"Expected non-negative integer, got character" % ↕"hi"
|
||
!"↕: Argument must be either an integer or integer list (had rank 2)" % ↕2‿2⥊1
|
||
!"↕: Result rank too large (300≡≠𝕩)" % ↕300⥊1
|
||
|
||
# 𝕨↕𝕩
|
||
!"↕: Length of 𝕨 must be at most rank of 𝕩" % 0↕0
|
||
!"↕: Length of 𝕨 must be at most rank of 𝕩" % 0‿0↕3⥊1
|
||
0‿0↕3‿3⥊1 %% 4‿4‿0‿0⥊0
|
||
1↕↕2‿3 %% 2‿1‿3⥊↕2‿3
|
||
0↕↕3 %% 4‿0⥊0
|
||
|
||
# ≡𝕩
|
||
≡¨ ⟨⟨⟩, ↕0, ""⟩ %% 1‿1‿1
|
||
≡↕0‿0‿0 %% 1
|
||
≡⟨1,1‿2,1⟩ %% 2
|
||
≡⋈⍟100 0 %% 100
|
||
≡↕10 %% 1
|
||
≡0 %% 0
|
||
|
||
# 𝕨⥊𝕩
|
||
!"⥊: Result rank too large" % (0∾300⥊2)⥊0
|
||
|
||
# 𝕨⍷𝕩
|
||
%USE eqvar ⋄ "ab" ⍷_eqvar "" %% ⟨⟩
|
||
%USE eqvar ⋄ "" ⍷_eqvar "ab" %% 1‿1‿1
|
||
%USE eqvar ⋄ ⟨ ⟩ ⍷_eqvar ↕0 %% ⟨1⟩
|
||
%USE eqvar ⋄ ⟨{⇐} ⟩ ⍷_eqvar ↕0 %% ⟨⟩
|
||
%USE eqvar ⋄ ⟨0, 1 ⟩ ⍷_eqvar ↕0 %% ⟨⟩
|
||
%USE eqvar ⋄ ⟨{⇐},{⇐}⟩ ⍷_eqvar ↕0 %% ⟨⟩
|
||
%USE eqvar ⋄ (↕0) ⍷_eqvar 1‿0 %% 1‿1‿1
|
||
%USE eqvar ⋄ "ab" ⍷_eqvar 0‿5⥊"ab" %% 0‿4⥊0
|
||
(0⥊0)⍷1‿0⥊0 %% 1‿1⥊1
|
||
⟨⟩⍷1‿0⥊"" %% 1‿1⥊1
|
||
(0‿0‿0‿0‿0‿0⥊0)⍷1‿0‿0‿0‿0‿0‿0⥊0 %% 1‿1‿1‿1‿1‿1‿1⥊1
|
||
(0‿0‿0‿0‿0‿0⥊0)⍷3‿0‿0‿0‿3‿4‿0⥊0 %% 3‿1‿1‿1‿4‿5‿1⥊1
|
||
!"Out of memory" % (0‿0‿0‿0‿0‿0⥊0)⍷1e9‿0‿0‿1e9‿1e9‿0‿0⥊0
|
||
'a'‿1 ⍷ 0‿5⥊⟨⟩ %% 0‿4⥊0
|
||
"abc" ⍷ 5‿1⥊'a' %% 5‿0⥊0
|
||
⟨(<"ab")⍷<"aa", (<"ab")⍷<"ab"⟩ %% ⟨<0,<1⟩
|
||
{(=𝕨)≤=𝕩?𝕨⍷𝕩;'e'}⌜˜ ⟨'a','b',<'a','b',"a","b","aa","bb"⟩ %% (8‿8⥊⟨<1,<0,<1,<0,⟨1⟩,⟨0⟩,1‿1,0‿0,<0,<1,<0,<1,⟨0⟩,⟨1⟩,0‿0,1‿1,<1,<0,<1,<0,⟨1⟩,⟨0⟩,1‿1,0‿0,<0,<1,<0,<1,⟨0⟩,⟨1⟩,0‿0,1‿1,'e','e','e','e',⟨1⟩,⟨0⟩,1‿1,0‿0,'e','e','e','e',⟨0⟩,⟨1⟩,0‿0,1‿1,'e','e','e','e',⟨⟩,⟨⟩,⟨1⟩,⟨0⟩,'e','e','e','e',⟨⟩,⟨⟩,⟨0⟩,⟨1⟩⟩)
|
||
0∘⍷⎊1⌜˜ ⟨'a','b',<'a','b',"a","b","aa","bb",2‿2⥊'a'⟩ %% 9‿9⥊0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿0‿1‿1‿1‿1‿0‿0‿0‿0‿0‿1‿1‿1‿1‿0‿0‿0‿0‿0‿1‿1‿1‿1‿0‿0‿0‿0‿0‿1‿1‿1‿1‿0‿0‿0‿0‿0‿1‿1‿1‿1‿1‿1‿1‿1‿0
|
||
(5‿999‿0‿9‿10‿11‿12⥊"a") ⍷ 10‿20‿30‿0‿40‿50‿60‿70‿80‿10‿10‿10‿10⥊0 %% 10‿20‿30‿0‿40‿50‿56‿0‿81‿2‿1‿0‿0⥊0
|
||
|
||
# ⊐𝕩
|
||
⊐ (⊢∾¯1×⊢) 0‿1.5 %% 0‿1‿0‿2
|
||
|
||
# 𝕨⊒𝕩
|
||
1‿2‿2‿3‿3‿2‿2‿1⊒1‿8‿5‿5‿6‿2‿5‿3‿1‿5‿1‿2‿4‿3‿4‿3‿1‿5‿2‿3‿4‿1‿5‿2 %% 0‿8‿8‿8‿8‿1‿8‿3‿7‿8‿8‿2‿8‿4‿8‿8‿8‿8‿5‿8‿8‿8‿8‿6
|
||
|
||
# 𝕨∊𝕩, 𝕨⊐𝕩, 𝕨⊒𝕩
|
||
{! ∧´(𝕨∊𝕩) = 𝕨≡○⊑𝕩}⌜˜ 3‿100 ⥊⌜ "a⍉𝕩"∾1‿10‿1e4‿1e9‿1e12∾⟨"a",{⇐}⟩
|
||
{! ∧´(𝕨⊐𝕩) = (≠𝕨) × 𝕨≢○⊑𝕩}⌜˜ 3‿100 ⥊⌜ "a⍉𝕩"∾1‿10‿1e4‿1e9‿1e12∾⟨"a",{⇐}⟩
|
||
{! ∧´(𝕨⊒𝕩) = ↕∘≠⊸⌊⍟(𝕨≡○⊑𝕩) 𝕩 ⥊○≠ 𝕨}⌜˜ 3‿100 ⥊⌜ "a⍉𝕩"∾1‿10‿1e4‿1e9‿1e12∾⟨"a",{⇐}⟩
|
||
|
||
# 𝕨⍋𝕩
|
||
!"⍋: 𝕨 must be sorted" % a←-¨ ∧⋈¨ ↕10 ⋄ a⍋⋈¨↕10
|
||
⍷∘(⥊¨)⊸({! (𝕨⍋𝕩) ≡ (≢𝕩)⥊ (≠𝕨)×0≥𝕨 •Cmp○⊑ 𝕩}⌜) ⟨3, <3, 10⥊3, 'a', <'a', 10⥊'a'⟩
|
||
⍷∘(⥊¨)⊸({! (𝕨⍒𝕩) ≡ (≢𝕩)⥊ (≠𝕨)×0≤𝕨 •Cmp○⊑ 𝕩}⌜) ⟨3, <3, 10⥊3, 'a', <'a', 10⥊'a'⟩
|
||
|
||
# 𝕨|𝕩
|
||
{x←2⥊𝕨|𝕩 ⋄ ! x •internal.EEqual 𝕨‿𝕨|𝕩‿𝕩 ⋄ ! x •internal.EEqual 𝕨|𝕩‿𝕩}⌜˜ ⍷∧∾⟜- ⟨π, ∞, 0÷0, 0.5, 0.1⟩∾(↕10)∾⥊(¯4+↕9)+⌜2⋆7‿8‿15‿31‿32
|
||
(
|
||
# AS/SA/AA over types, 2-item array; %SLOW
|
||
%USE var ⋄ EE←•internal.EEqual
|
||
tests ← ⍷∧∾⟜- ⟨π, ∞, 0÷0, 0.5, 0.1⟩∾(↕10)∾⥊(¯4+↕9)+⌜2⋆7‿8‿15‿31‿32
|
||
{w𝕊x:
|
||
wl‿xl←2⥊¨w‿x
|
||
w‿x ! ∧´(⊏EE¨⊢) ⥊ wl {⟨ w|(𝕩 V xl) ⋄ (𝕨 V wl)|x ⋄ (𝕨 V wl)|(𝕩 V xl) ⟩}⌜○LV xl
|
||
CLR@
|
||
}⌜˜ tests
|
||
)
|
||
(
|
||
# 1|scalar vs 1|f64arr over float exponents %SLOW
|
||
{𝕩! (1⊸| •internal.EEqual 1|¨⊢) ∾⟜- (2⋆𝕩)×1‿1.5∾1000•rand.Range 0}¨ ¯1080+↕2110
|
||
)
|
||
# 𝕨÷𝕩
|
||
!"÷: Unexpected argument types" % ⟨1‿2, "ab"⟩÷2
|
||
50⊑"7.299999247803105e-309" {(100⥊𝕨)÷𝕩}○•ParseFloat "0.34361186623573303" %% •ParseFloat "2.1244898576334326e-308"
|
||
50⊑"3.8863870613495216e-308" {(100⥊𝕨)÷𝕩}○•ParseFloat "0.3815327155289232" %% •ParseFloat "1.0186248526451468e-307"
|
||
|
||
|
||
|
||
|
||
# ⍟
|
||
%USE eqvar ⋄ a←¯5+↕10 ⋄ {1⊸+⍟𝕩 ⋈10}_eqvar a %% ⋈¨ 5+↕10
|
||
%USE eqvar ⋄ a←¯5+↕10 ⋄ {1+⍟𝕩 ⋈10}_eqvar a %% ⋈¨ 5+↕10
|
||
%USE eqvar ⋄ a←¯5+↕10 ⋄ {1+⍟(𝕩{!𝕩≡⋈10 ⋄ 𝕗}) ⋈10}_eqvar a %% ⋈¨ 5+↕10
|
||
!∘0⍟⟨↕0, ⟨⟩, ""⟩ 0 %% ⟨⟨⟩,⟨⟩,⟨⟩⟩
|
||
!"Calling a modifier" % 1⊸+⍟{∘} 0
|
||
!"⍟: 𝔾 contained non-number" % 1⊸+⍟⟨1,∘,3⟩ 0
|
||
!"Expected integer, got 1.5" % 1⊸+⍟1.5 0
|
||
!"Integer out of range: 1e20" % 1⊸+⍟1e20 0
|
||
!"⍟: 𝔾 contained non-integer (or integer was out of range)" % %USE evar ⋄ {1⊸+⍟𝕩 0}_evar ⟨1.5⟩
|
||
!"⍟: 𝔾 contained non-integer (or integer was out of range)" % %USE evar ⋄ {1⊸+⍟𝕩 0}_evar ⟨1e20⟩
|
||
!"⍟: 𝔾 contained non-integer (or integer was out of range)" % %USE evar ⋄ {1⊸+⍟𝕩 0}_evar ⟨9, 1.5⟩
|
||
!"⍟: 𝔾 contained non-integer (or integer was out of range)" % %USE evar ⋄ {1⊸+⍟𝕩 0}_evar ⟨1.5, 9⟩
|
||
|
||
# ◶
|
||
!"◶: 𝕘 must have rank 1 when index is a number" % 1◶[1‿2,3‿4] 3
|
||
!"◶: 𝕘 must have rank 1 when index is a number" % "ab" ⊢◶[1‿2,3‿4] 3
|
||
!"⊑: Picking item at wrong rank (index 0‿0 in array of shape ⟨2⟩)" % ⊢◶+‿- 0‿0 # shouldn't reference ⊑ but whatever
|
||
!"⊑: Picking item at wrong rank (index 1‿2 in array of shape ⟨3⟩)" % 1 +◶+‿-‿⊢ 0‿1
|
||
10 +◶"ab"‿"cd" ¯9 %% "cd"
|
||
⟨⋈1,⋈2,⋈0⟩◶"ab"‿"cd"‿1 @ %% "cd"‿1‿"ab"
|
||
|
||
|
||
# ˘ & ⎉
|
||
≢ (1⥊˜ 0∾203⥊2)⎉50 1⥊˜ 0∾100⥊2 %% 1‿50‿1‿203/0‿2‿0‿2
|
||
!"⎉: Result rank too large" % (1⥊˜ 0∾203⥊2)⎉49 1⥊˜ 0∾100⥊2
|
||
!"˘: Result rank too large" % ((255⥊1)⥊1)˘ 1‿2
|
||
|
||
# `
|
||
!"`: Shape of 𝕨 must match the cell of 𝕩 (2‿2 ≡ ≢𝕨, 3‿2‿3 ≡ ≢𝕩)" % (2‿2⥊1)+`↕3‿2‿3
|
||
!"`: Shape of 𝕨 must match the cell of 𝕩 (2‿2 ≡ ≢𝕨, 3‿3‿2 ≡ ≢𝕩)" % (2‿2⥊1)+`↕3‿3‿2
|
||
!"`: Shape of 𝕨 must match the cell of 𝕩 (⟨⟩ ≡ ≢𝕨, 3‿3 ≡ ≢𝕩)" % 2+`↕3‿3
|
||
|
||
# ´
|
||
!"´: Argument must be a list (3‿3 ≡ ≢𝕩)" % +´↕3‿3
|
||
!"´: 𝕩 must be a list (3‿3 ≡ ≢𝕩)" % 2+´↕3‿3
|
||
+⌜´↕0 %% <0
|
||
×⌜´↕0 %% <1
|
||
+⌜⌜⌜´↕0 %% <<<0
|
||
×⌜⌜⌜´↕0 %% <<<1
|
||
|
||
# ⌜
|
||
!"⌜: Result rank too large (200≡=𝕨, 200≡=𝕩)" % +⌜˜(200⥊1)⥊1
|
||
|
||
# ˜
|
||
5˜˝ "ab" %% 5
|
||
5˜⌜˜ "a" %% [[5]]
|
||
5˜˝˘≍"ab" %% ⟨5⟩
|