Merge branch 'master' into pr/287
This commit is contained in:
commit
b2c51d0130
1
AUTHORS
1
AUTHORS
@ -16,3 +16,4 @@
|
|||||||
* Guillermo Vayá <guivaya@gmail.com>
|
* Guillermo Vayá <guivaya@gmail.com>
|
||||||
* Bob Tolbert <bob@tolbert.org>
|
* Bob Tolbert <bob@tolbert.org>
|
||||||
* Ralph Möritz <ralph.moeritz@outlook.com>
|
* Ralph Möritz <ralph.moeritz@outlook.com>
|
||||||
|
* Josh McLaughlin <josh@phear.cc>
|
||||||
|
@ -270,6 +270,27 @@ Return True if x is greater than zero (0).
|
|||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
|
.. _zero?-fn:
|
||||||
|
|
||||||
|
zero?
|
||||||
|
----
|
||||||
|
|
||||||
|
Usage: ``(zero? x)``
|
||||||
|
|
||||||
|
Return True if x is zero (0).
|
||||||
|
|
||||||
|
.. code-block:: clojure
|
||||||
|
|
||||||
|
=> (zero? 3)
|
||||||
|
False
|
||||||
|
|
||||||
|
=> (zero? -2)
|
||||||
|
False
|
||||||
|
|
||||||
|
=> (zero? 0)
|
||||||
|
True
|
||||||
|
|
||||||
|
|
||||||
Sequence Functions
|
Sequence Functions
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
@ -154,7 +154,12 @@
|
|||||||
(yield val)
|
(yield val)
|
||||||
(break)))))
|
(break)))))
|
||||||
|
|
||||||
|
(defn zero? [n]
|
||||||
|
"Return true if n is 0"
|
||||||
|
(_numeric_check n)
|
||||||
|
(= n 0))
|
||||||
|
|
||||||
(def *exports* ["cycle" "dec" "distinct" "drop" "even?" "filter" "inc"
|
(def *exports* ["cycle" "dec" "distinct" "drop" "even?" "filter" "inc"
|
||||||
"instance?" "iterable?" "iterate" "iterator?" "neg?"
|
"instance?" "iterable?" "iterate" "iterator?" "neg?"
|
||||||
"none?" "nth" "numeric?" "odd?" "pos?" "remove" "repeat"
|
"none?" "nth" "numeric?" "odd?" "pos?" "remove" "repeat"
|
||||||
"repeatedly" "take" "take_nth" "take_while"])
|
"repeatedly" "take" "take_nth" "take_while" "zero?"])
|
||||||
|
@ -181,6 +181,18 @@
|
|||||||
(try (do (neg? None) (assert False))
|
(try (do (neg? None) (assert False))
|
||||||
(catch [e [TypeError]] (assert (in "not a number" (str e))))))
|
(catch [e [TypeError]] (assert (in "not a number" (str e))))))
|
||||||
|
|
||||||
|
(defn test-zero []
|
||||||
|
"NATIVE: testing the zero? function"
|
||||||
|
(assert-false (zero? -2))
|
||||||
|
(assert-false (zero? 1))
|
||||||
|
(assert-true (zero? 0))
|
||||||
|
(try (do (zero? "foo") (assert False))
|
||||||
|
(catch [e [TypeError]] (assert (in "not a number" (str e)))))
|
||||||
|
(try (do (zero? []) (assert False))
|
||||||
|
(catch [e [TypeError]] (assert (in "not a number" (str e)))))
|
||||||
|
(try (do (zero? None) (assert False))
|
||||||
|
(catch [e [TypeError]] (assert (in "not a number" (str e))))))
|
||||||
|
|
||||||
(defn test-none []
|
(defn test-none []
|
||||||
"NATIVE: testing for `is None`"
|
"NATIVE: testing for `is None`"
|
||||||
(assert-true (none? None))
|
(assert-true (none? None))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user