That doesn't work in Dyalog APL, comes back with RANK ERROR.
It's idiomatic to pick ⊃ the first result of ⎕NGET to get just the lines to work on, and not the other things like file encoding.
Then grade-up-right-train-each (⍋⊢)¨ is redunant, it's the same as grade-up-each ⍋¨
The grade is an array of which indices to take to put the argument in sorted order and I don't think it makes sense to group ⌸ by that since the grade isn't the same for different arrangements of letters, so the whole approach breaks down there. I think the words have to be sorted, e.g to pick out 'bat' and 'tab' as the same letters:
Then 1<≢¨ would be "1 is less than the count (tally) of each" which fits somewhere in the solution, but not there and won't work on my array. We don't need to know the actual sorted letters so we can inline the bitmask of which answers matter or not in the first column:
Any with a 1 in the first column are anagrams, and 0 in the first column are not. And the other columns are indices into the wordlist where the matching words are, so words[1,3] picks out 'bat' and 'tab' and it's probably possible to filter rows with 1 in the first column:
It can probably be done shorter and cleaner with more skill than I have. It's a lot quicker to execute than the PowerShell version I commented, but took a lot longer to code.
(That expands to {⍵[⍋⍵]}¨words to sort each word, then use that on the left of Key ⌸ with words on the right, and Key feeds the count and indices into the custom function which is ⊢∘⊂ that takes the indicies with right-tack ⊢ and throws away the count, and encloses them with ⊂. That gives nested arrays of words which sort the same, including invididual words that sort like nothing else. Then (⊢⊢⍤/⍨1<≢¨) added to the left is counting the words in each nesting and filtering out the single ones, and I think ⊢⍤/ is a bodge to use compress in a train without it being misread as reduce when both use the same symbol / ?)
It's idiomatic to pick ⊃ the first result of ⎕NGET to get just the lines to work on, and not the other things like file encoding.
Then grade-up-right-train-each (⍋⊢)¨ is redunant, it's the same as grade-up-each ⍋¨
The grade is an array of which indices to take to put the argument in sorted order and I don't think it makes sense to group ⌸ by that since the grade isn't the same for different arrangements of letters, so the whole approach breaks down there. I think the words have to be sorted, e.g to pick out 'bat' and 'tab' as the same letters:
Then 1<≢¨ would be "1 is less than the count (tally) of each" which fits somewhere in the solution, but not there and won't work on my array. We don't need to know the actual sorted letters so we can inline the bitmask of which answers matter or not in the first column: Any with a 1 in the first column are anagrams, and 0 in the first column are not. And the other columns are indices into the wordlist where the matching words are, so words[1,3] picks out 'bat' and 'tab' and it's probably possible to filter rows with 1 in the first column: and then drop the first column: Then uhh filter out the zeros to avoid index error, and index into the word list, so: It can probably be done shorter and cleaner with more skill than I have. It's a lot quicker to execute than the PowerShell version I commented, but took a lot longer to code.