/anagram.clj Secret
Created
June 27, 2014 19:18
This file contains 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
(ns anagram | |
[:require [clojure.string :as str]]) | |
(defn anagram? [word possible-anagram] | |
(and | |
(not= word possible-anagram) | |
(= (sort possible-anagram) | |
(sort word)))) | |
(defn case-insensitive-anagram? [word possible-anagram] | |
(anagram? | |
(str/lower-case word) | |
(str/lower-case possible-anagram))) | |
(defn anagrams-for [word word-list] | |
(vec | |
(filter | |
#(case-insensitive-anagram? word %) | |
word-list))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment