Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Clojure: define the unless function and use in examples

View unless.clj
1 2 3 4 5 6 7 8 9
(defn unless [test expr] (if-not (eval test) (eval expr)))
(prn (unless (odd? 11) (str "it's good to be " 11)))
(prn (unless (odd? 12) (str "it's good to be " 12)))
(defn only-if-even [x] (unless (odd? x) (str "it's good to be " x)))
(prn (str 6 " " (only-if-even 6)))
(prn (str 5 " " (only-if-even 5)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.