Clojure-even
提供:Dev Guides
Clojure-でも?
数値が偶数の場合はtrueを返し、数値が整数でない場合は例外をスローします。
構文
構文は次のとおりです。
(even? number)
例
偶数テスト関数の例を次に示します。
(ns clojure.examples.hello
(:gen-class))
;; This program displays Hello World
(defn Example []
(def x (even? 0))
(println x)
(def x (even? 2))
(println x)
(def x (even? 3))
(println x))
(Example)
出力
上記のプログラムは、次の出力を生成します。
true
true
false