Created
November 15, 2021 22:15
-
-
Save nickbauman/4d90d866bf0bc3db3ba2d46ed1c484bb to your computer and use it in GitHub Desktop.
Clojure anagram detector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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