The following APL question on Stack Overflow piqued my curiosity: https://stackoverflow.com/questions/51730263/length-error-while-creating-a-dfn-function-in-apl-to-check-for-anagrams <https://stackoverflow.com/questions/51730263/length-error-while-creating-a-dfn-function-in-apl-to-check-for-anagrams>
Essentially, the user is looking for a dyad `anagram` which gives 1 for words that are anagrams of each other, ignoring spaces, i.e.: 'ALBERT EINSTEIN' anagram 'TEN ELITE BRAINS' 1 'ALBERT EINSTEIN' anagram 'NOT ELITE BRAINS' 0 'ALBART EINSTEIN' anagram 'TEN ELITE BRAINS' 0 My solution: hash =: [: /:~ ] #~ ' ' ~: ] anagram =: *./ @: =&hash I’d appreciate feedback if I’m missing an obvious way to increase the clarity of this. I’m also wondering if the “anagram index” builtin A. can be used to solve this problem somehow; it isn’t obvious to me that it can. Thanks! -- Daniel Lyons ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
