Skip to content

Instantly share code, notes, and snippets.

@harmenjanssen
harmenjanssen / nearest-vowels.clj
Created May 5, 2020 07:17
nearest-vowels Clojure kata
(def vowels "aeiou")
(defn is-vowel [ch] (not (nil? (some #{ch} vowels))))
(defn abs [n] (max n (- n)))
(defn distance
"Returns the distance from the number x to the closest number in xs"
[xs x]
(apply min (map (fn [y] (abs (- y x))) xs)))