src/anagram.clj

1
2
3
4
5
6
7
8
9
10
11
(ns anagram
  (:require [clojure.string :refer [lower-case]]))

(defn anagrams? [& words]
  (let [lcwords (map lower-case words)]
    (and
      (apply = (map sort lcwords))
      (apply not= lcwords))))

(defn anagrams-for [word candidates]
  (filter (partial anagrams? word) candidates))

Comments

Decided to go for a potentially more useful version of anagrams? that will test any number of words - and teach myself how to do varargs in the process :)

helenst commented 24 March 2016 at 10:56 UTC

You're not logged in right now. Please login via GitHub to comment