Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2011 09:24
Show Gist options
  • Save anonymous/953064 to your computer and use it in GitHub Desktop.
Save anonymous/953064 to your computer and use it in GitHub Desktop.
;; chrisvest's solution to http://4clojure.com/problem/74
(fn [s]
(let [perfect-square
(fn [n] (loop [i 1]
(cond
(= n (* i i)) true
(< n (* i i)) false
:else (recur (inc i)))))]
(->> s
(re-seq #"\d+")
(map #(Integer/parseInt %))
(filter perfect-square)
(interpose ",")
(apply str))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment