Clojure - neg?


Advertisements

Returns true if number is less than zero, else false.

Syntax

Following is the syntax.

(neg? number)

Example

Following is an example of the neg test function.

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x (neg? -1))
   (println x)
   
   (def x (neg? 0))
   (println x)
  
   (def x (neg? 1))
   (println x))
(Example)

Output

The above program produces the following output.

true
false
false
clojure_numbers.htm
Advertisements