Skip to content

Instantly share code, notes, and snippets.

@angusb
Created October 11, 2012 04:56
Show Gist options
  • Save angusb/3870261 to your computer and use it in GitHub Desktop.
Save angusb/3870261 to your computer and use it in GitHub Desktop.
Function from hell
; Given a string of comma separated integers, write a function which
; returns a new comma separated string that only contains the numbers
; which are perfect squares.
(fn [s]
(apply str
(interpose \,
(filter #(= (Math/sqrt %)
(Math/floor (Math/sqrt %)))
(map #(Integer/parseInt %)
(re-seq #"\w+" s))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment