💾 Archived View for blitter.com › apl-examples › anagram › anagram-example.apl.txt captured on 2024-08-25 at 03:20:45.

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