if-not

added
1.0

ns
clojure.core

type
macro

(if-not test then) (if-not test then else)

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
            
                user=> (if-not (zero? 0) :then :else)
:else
            
                ;; See examples for "if" explaining Clojure's idea of logical true
;; and logical false.