Fork me on GitHub
Chris Chambers18:04:23

@porkostomus A similar problem to the original problem with spec being absent, I guess? Feature completeness vs. responsivity, as you mentioned

Bobbi Towers20:04:44

@magma.chambers what code is giving that error?

Chris Chambers21:04:04

(ns anagram
  (:require [clojure.string :as str]
            [clojure.core.reducers :as r]))
(defn anagrams-for
  "Filter `candidates` for valid anagrams of `word`."
  [word candidates]
  (let* [word (str/lower-case word)
         sorted (sort word)]
        (r/foldcat (r/filter #(= sorted (-> % str/lower-case sort))
                             (remove #{word} candidates)))))

Chris Chambers21:04:57

I know that strictly speaking reducers are overkill here, and I could easily do it with a standard filterv , but I like to use these exercises to learn the important clojure libs