Merge branch 'master' of github.com:hylang/hy

This commit is contained in:
Paul Tagliamonte 2013-12-30 17:33:07 -05:00
commit a5b56be83e
5 changed files with 29 additions and 3 deletions

View File

@ -575,6 +575,26 @@ See also :ref:`remove-fn`.
=> (list (filter even? [1 2 3 -4 5 -7])) => (list (filter even? [1 2 3 -4 5 -7]))
[2, -4] [2, -4]
.. _flatten-fn:
flatten
-------
.. versionadded:: 0.9.12
Usage: ``(flatten coll)``
Return a single list of all the items in ``coll``, by flattening all
contained lists and/or tuples.
.. code-block:: clojure
=> (flatten [1 2 [3 4] 5])
[1, 2, 3, 4, 5]
=> (flatten ["foo" (, 1 2) [1 [2 3] 4] "bar"])
['foo', 1, 2, 1, 2, 3, 4, 'bar']
.. _iterate-fn: .. _iterate-fn:

View File

@ -229,6 +229,7 @@ def t_identifier(p):
table = { table = {
"true": "True", "true": "True",
"false": "False", "false": "False",
"nil": "None",
"null": "None", "null": "None",
} }

View File

@ -86,9 +86,10 @@
(defn test-is [] (defn test-is []
"NATIVE: test is can deal with None" "NATIVE: test is can deal with None"
(setv a null) (setv a nil)
(assert (is a null)) (assert (is a nil))
(assert (is-not a "b"))) (assert (is-not a "b"))
(assert (none? a)))
(defn test-branching [] (defn test-branching []

View File

@ -4,5 +4,7 @@
(assert (= (unless false 1 2) 2)) (assert (= (unless false 1 2) 2))
(assert (= (unless false 1 3) 3)) (assert (= (unless false 1 3) 3))
(assert (= (unless true 2) null)) (assert (= (unless true 2) null))
(assert (= (unless true 2) nil))
(assert (= (unless (!= 1 2) 42) null)) (assert (= (unless (!= 1 2) 42) null))
(assert (= (unless (!= 1 2) 42) nil))
(assert (= (unless (!= 2 2) 42) 42))) (assert (= (unless (!= 2 2) 42) 42)))

View File

@ -5,4 +5,6 @@
(assert (= (when true 1 3) 3)) (assert (= (when true 1 3) 3))
(assert (= (when false 2) null)) (assert (= (when false 2) null))
(assert (= (when (= 1 2) 42) null)) (assert (= (when (= 1 2) 42) null))
(assert (= (when false 2) nil))
(assert (= (when (= 1 2) 42) nil))
(assert (= (when (= 2 2) 42) 42))) (assert (= (when (= 2 2) 42) 42)))