Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Clojure: define the unless function and use in examples
(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