Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2013 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5653546 to your computer and use it in GitHub Desktop.
Save anonymous/5653546 to your computer and use it in GitHub Desktop.
;; Write a sine wave
(def lines-per-period 30)
(def line-width 80)
(defn write-period []
(dotimes [line lines-per-period]
(let [columns (vec (repeat line-width " "))
sine (Math/sin (* (* Math/PI 2)
(double (/ line lines-per-period))))
sine-scaled (/ (+ 1 sine) 2)
sine-column (int (* line-width sine-scaled))
columns-starred (assoc columns sine-column "*")]
(println (apply str columns-starred)))))
(write-period)
(write-period)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment