Clojure – Logical Operators

clojure logical operators

In this guide, we will discuss Clojure Logical Operators. Logical operators are used to evaluate Boolean expressions. Following are the logical operators available in Groovy.

OperatorDescriptionExample
andThis is the logical “and” operator(or true true) will give true
orThis is the logical “or” operator(and true false) will give false
notThis is the logical “not” operator(not false) will give true

The following code snippet shows how the various operators can be used.

Example

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

;; This program displays Hello World
(defn Example []
   (def x (or true true))
   (println x)
   
   (def x (and true false))
   (println x)
   
   (def x (not true))
   (println x))
(Example)

The above program produces the following output.

Output

true
false
false

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply