Clojure-logical-operators

提供:Dev Guides
移動先:案内検索

Clojure-論理演算子

論理演算子は、ブール式を評価するために使用されます。 以下は、Groovyで使用可能な論理演算子です。

Operator Description Example
and This is the logical “and” operator (or true true) will give true
or This is the logical “or” operator (and true false) will give false
not This is the logical “not” operator (not false) will give true

次のコードスニペットは、さまざまな演算子の使用方法を示しています。

(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)

上記のプログラムは、次の出力を生成します。

出力

true
false
false