Clojure-zero

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

Clojure-ゼロ?

数値がゼロの場合はtrue、そうでない場合はfalseを返します。

構文

構文は次のとおりです。

(zero? number)

以下は、ゼロテスト関数の例です。

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

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

   (def x (zero? 0.0))
   (println x)

   (def x (zero? 1))
   (println x))
(Example)

出力

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

true
true
false