Skip to content

Instantly share code, notes, and snippets.

@zspencer
Created April 17, 2015 15:07
Show Gist options
  • Save zspencer/d9ab34dfd468318bb053 to your computer and use it in GitHub Desktop.
Save zspencer/d9ab34dfd468318bb053 to your computer and use it in GitHub Desktop.
Drop this into lighttable and Cmd+enter!
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(defn fizz? [number]
(zero? (rem number 3)))
(fizz? 1)
(fizz? 3)
(fizz? 6)
(fizz? 10)
(defn buzz? [number]
(zero? (rem number 5)))
(buzz? 3)
(buzz? 5)
(buzz? 7)
(buzz? 10)
(defn fizz-buzz? [number]
(and (fizz? number) (buzz? number)))
(fizz-buzz? 1)
(fizz-buzz? 3)
(fizz-buzz? 5)
(fizz-buzz? 7)
(fizz-buzz? 9)
(fizz-buzz? 15)
(defn fizz-buzz [number]
(cond
(fizz-buzz? number) "fizz-buzz"
(fizz? number) "fizz"
(buzz? number) "buzz"
:else number))
(fizz-buzz 1)
(fizz-buzz 3)
(fizz-buzz 5)
(fizz-buzz 7)
(fizz-buzz 12)
(fizz-buzz 15)
(map fizz-buzz (range 1 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment