Skip to content

Instantly share code, notes, and snippets.

@xpqz
Last active July 7, 2021 14:13
Show Gist options
  • Save xpqz/90b99e3906a2deaa002ef4cf811e9ae1 to your computer and use it in GitHub Desktop.
Save xpqz/90b99e3906a2deaa002ef4cf811e9ae1 to your computer and use it in GitHub Desktop.
Find length-3 expressions that evaluate to `0 0⍴⍬` in Dyalog APL
r←Brutus;glyphs;combo;eval
glyphs ← '0⍬+-×÷*⍟⌹○|⌈⌊⊥⊤⊣⊢=≠≤<>≥≡≢∨∧⍲⍱↑↓⊂⊃⊆⌷⍋⍒⍳⍸∊⍷∪∩~/\⌿⍀,⍪⍴⌽⊖⍉¨⍨⍣.∘⍤⍥@⌸⌺⍎⍕¯'
r←⍬
:for combo :in ,∘.,⍣2⍨glyphs
:trap 0
eval ← ⍎combo
:else
:continue
:endtrap
:if eval≡0 0⍴⍬
r,←⊂combo
:endif
:endfor
@xpqz
Copy link
Author

xpqz commented Jul 7, 2021

Adam says:

@xpqz I disagree that all the Key ones are the same.
Only all the scalar operands are the same.
@xpqz ⊤⌸⍬ ⊢⌸⍬ ↑⌸⍬ (same as ↓⌸⍬) ⍷⌸⍬ ∩⌸⍬ /⌸⍬ (same as ⌿⌸⍬) ⍴⌸⍬ ⌽⌸⍬ (same as ⊖⌸⍬) are all interesting. I don't see how ⍉⌸⍬ works.
So, a blog post explaining each of these dozen approaches… Sounds like interesting reading to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment