Created
May 26, 2013 18:05
-
-
Save anonymous/5653546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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