Last active
July 7, 2021 14:13
-
-
Save xpqz/90b99e3906a2deaa002ef4cf811e9ae1 to your computer and use it in GitHub Desktop.
Find length-3 expressions that evaluate to `0 0⍴⍬` in Dyalog APL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
A CMC was posed: find shortest expression evaluating to
0 0⍴⍬
in Dyalog APL. Typing that into APLCard yields⍬⊤⍬
, but there are actually loads. The above function constructs all possible length-3 expressions from a subset of the APL glyphs, evaluates them in turn and looks for matches:We can think of all the Key ones being the same, so the interesting ones are:
⍬⊤⍬
⊤⍨⍬
-- same as above, reallyf ⌸⍬
-- all the Key ones↑⍸0