SHARE
TWEET

FizzBuzz in Clojure with cond

ptrelford Sep 25th, 2014 (edited) 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (map
  2.  (fn [x]
  3.    (let [a (mod x 3) b (mod x 5)]
  4.      (cond
  5.       (and (= a 0) (= b 0)) (str "FizzBuzz")
  6.       (= a 0) (str "Fizz")
  7.       (= b 0) (str "Buzz")
  8.       :else (str x)
  9.      )
  10.    )
  11.  )
  12.  (range 1 100)
  13. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top