Skip to content

Instantly share code, notes, and snippets.

@nickbauman
Created November 15, 2021 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickbauman/4d90d866bf0bc3db3ba2d46ed1c484bb to your computer and use it in GitHub Desktop.
Save nickbauman/4d90d866bf0bc3db3ba2d46ed1c484bb to your computer and use it in GitHub Desktop.
Clojure anagram detector
(defn split-string [word]
(into #{} (clojure.string/split word #"")))
(defn anagram-of? [word candidate]
(boolean (when (= (count word) (count candidate))
(let [word-list (split-string word)
cand-list (split-string candidate)]
(= #{} (clojure.set/difference cand-list word-list))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment