Clojure - odd?



如果數字是奇數,則返回 true,如果數字不是整數,則丟擲異常。

語法

以下是語法。

(odd? number)

示例

以下是 odd 測試函式的示例。

(ns clojure.examples.hello
   (:gen-class))
;; This program displays Hello World
(defn Example []
   (def x (odd? 0))
   (println x)
   
   (def x (odd? 2))
   (println x)
   
   (def x (odd? 3))
   (println x))
(Example)

輸出

上述程式生成以下輸出。

false
false
true
clojure_numbers.htm
廣告