Skip to content

Instantly share code, notes, and snippets.

@thanthese
Created August 24, 2011 13:07
Show Gist options
  • Save thanthese/1168020 to your computer and use it in GitHub Desktop.
Save thanthese/1168020 to your computer and use it in GitHub Desktop.
(def radius (if (empty? *command-line-args*)
12
(Integer/parseInt (first *command-line-args*))))
(defn stream [radius]
(let [full-range (range (- radius)
(inc radius))]
(for [x full-range
y full-range
z full-range]
(if (> radius (Math/sqrt (+ (* x x)
(* y y)
(* z z))))
"x"
"-"))))
(let [diameter (inc (* 2 radius))]
(doseq [[i n] (map vector (iterate inc 0) (stream radius))]
(when (= 0 (mod i diameter)) (print "\n"))
(when (= 0 (mod i (* diameter diameter))) (print "\n"))
(print n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment