💾 Archived View for blitter.com › apl-examples › anagram › anagram-example.apl.txt captured on 2023-07-22 at 16:20:30.

View Raw

More Information

⬅️ Previous capture (2023-05-24)

-=-=-=-=-=-=-

#!/usr/bin/env  apl --script

word←'listen'
candidates←'enlists' 'google' 'inlets' 'banana' 'tinsel'

∇r ← word is_anagram_of other
  r ← word[⍋word] ≡ other[⍋other]
∇

((⊂word) is_anagram_of ¨ candidates)/candidates

⍝⍝ NB. GNU APL also supports 'dfns' (simple lambdas). An equivalent
⍝⍝ solution using dfn syntax:
⍝⍝   ((⊂word) {⍺[⍋⍺] ≡ ⍵[⍋⍵]} ¨ candidates)/candidates