Evaluates test. If logical false, evaluates and returns then expr,
otherwise else expr, if supplied, else nil.
user=> (defn has-neg [coll]
(if-not (empty? coll) ;; = (if (not (empty? coll)) ...
(or (neg? (first coll)) (recur (rest coll)))))
#'user/has-neg
user=> (has-neg [])
nil
user=> (has-neg [1 2 -3 4])
true
(defmacro if-not
"Evaluates test. If logical false, evaluates and returns then expr,
otherwise else expr, if supplied, else nil."
{:added "1.0"}
([test then] `(if-not ~test ~then nil))
([test then else]
`(if (not ~test) ~then ~else)))
Comments top
No comments for if-not. Log in to add a comment.