neg method is a number test method used to test if a number is less than zero. It only accepts one numeric parameter. The
neg method returns true for inputs less than zero and false for inputs greater than or equal to zero. The code line below shows the syntax for the
neg function is particularly useful when the user wishes to confirm if their calculations did not yield a negative value. It can promptly confirm if a number variable stores a value that is less than zero.
(ns clojure.examples.hello (:gen-class)) (defn negg  (def x (neg? 0)) (println x) (def x (neg? -1)) (println x) (def x (neg? 9)) (println x)) (negg)
negreturns false for the input
0since 0 is non-negative.
negmethod is true.
neggdefined in lines 4–12.
View all Courses