Hello, I am trying an exercise that finds anagrams of a word from a list of candidate words.
I am having issues with scalar extension of the left arg, which I thought should automatically repeat the scalar left arg to match each item in the right vector arg. It seems to work only if I do the expansion manually (that is, repeat the left arg explicitly rather than let APL do it). (If formatting below is not readable, please convert it to a fixed-with font) w > ┌→─────┐ > │listen│ > └──────┘ > cl > ┌→────────────────────────────────────────────┐ > │┌→──────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│ > ││enlists│ │google│ │inlets│ │banana│ │tinsel││ > │└───────┘ └──────┘ └──────┘ └──────┘ └──────┘│ > └∊────────────────────────────────────────────┘ > ⎕cr 'is_anagram_of' > ┌→──────────────────────────────┐ > ↓r ← word is_anagram_of other │ > │r ← word[⍋word] ≡ other[⍋other]│ > └───────────────────────────────┘ > w is_anagram_of cl > 0 > w is_anagram_of ¨ cl ⍝ <-- Should this not implicitly expand > left arg? > DOMAIN ERROR > is_anagram_of[1] r←word[⍋word]≡other[⍋other] > ^ ^ > w w w w w is_anagram_of cl ⍝ <-- this works, w w w w w matches > ⍴cl > 0 > w w w w w is_anagram_of ¨ cl > ┌→────────┐ > │0 0 1 0 1│ > └─────────┘ > (w w w w w is_anagram_of ¨ cl)/cl > ┌→────────────────┐ > │┌→─────┐ ┌→─────┐│ > ││inlets│ │tinsel││ > │└──────┘ └──────┘│ > └∊────────────────┘ > (∊1 (⍴cl))⍴⊂w > ┌→───────────────────────────────────────────┐ > ↓┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│ > ││listen│ │listen│ │listen│ │listen│ │listen││ > │└──────┘ └──────┘ └──────┘ └──────┘ └──────┘│ > └∊───────────────────────────────────────────┘ > w w w w w > ┌→───────────────────────────────────────────┐ > │┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│ > ││listen│ │listen│ │listen│ │listen│ │listen││ > │└──────┘ └──────┘ └──────┘ └──────┘ └──────┘│ > └∊───────────────────────────────────────────┘ > ((∊1 (⍴cl))⍴⊂w) is_anagram_of ¨ cl ⍝ <-- ?? Why does this not > work as (w w w w w)? > RANK ERROR > ((∈1(⍴cl))⍴⊂w)is_anagram_of¨cl > ^ ^ Advice appreciated, Thank you, -Russ