Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created June 27, 2014 19:18
(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