add tuple?
function hy.core
`tuple?` will test if the argument is an instance of tuple.
This commit is contained in:
parent
c415c6c907
commit
d793cee90a
1
NEWS.rst
1
NEWS.rst
@ -12,6 +12,7 @@ New Features
|
||||
* Format strings with embedded Hy code (e.g., `f"The sum is {(+ x y)}"`)
|
||||
are now supported, even on Pythons earlier than 3.6.
|
||||
* New list? function.
|
||||
* New tuple? function.
|
||||
|
||||
Bug Fixes
|
||||
------------------------------
|
||||
|
@ -951,6 +951,25 @@ Returns ``True`` if *x* is a symbol.
|
||||
=> (symbol? '[a b c])
|
||||
False
|
||||
|
||||
|
||||
.. _tuple?-fn:
|
||||
|
||||
tuple?
|
||||
------
|
||||
|
||||
Usage: ``(tuple? x)``
|
||||
|
||||
Returns ``True`` if *x* is a tuple.
|
||||
|
||||
.. code-block:: hy
|
||||
|
||||
=> (tuple? (, 42 44))
|
||||
True
|
||||
|
||||
=> (tuple? [42 44])
|
||||
False
|
||||
|
||||
|
||||
.. _zero?-fn:
|
||||
|
||||
zero?
|
||||
|
@ -206,6 +206,9 @@ Return series of accumulated sums (or other binary function results)."
|
||||
(defn list? [x]
|
||||
(isinstance x list))
|
||||
|
||||
(defn tuple? [x]
|
||||
(isinstance x tuple))
|
||||
|
||||
(defn symbol? [s]
|
||||
"Check if `s` is a symbol."
|
||||
(instance? HySymbol s))
|
||||
@ -461,4 +464,4 @@ Even objects with the __name__ magic will work."
|
||||
macroexpand-1 mangle map merge-with multicombinations name neg? none? nth
|
||||
numeric? odd? partition permutations pos? product range read read-str
|
||||
remove repeat repeatedly rest reduce second some string string? symbol?
|
||||
take take-nth take-while unmangle xor tee zero? zip zip-longest])
|
||||
take take-nth take-while tuple? unmangle xor tee zero? zip zip-longest])
|
||||
|
@ -272,6 +272,11 @@ result['y in globals'] = 'y' in globals()")
|
||||
(assert-false (list? "hello"))
|
||||
(assert-true (list? [1 2 3])))
|
||||
|
||||
(defn test-tuple? []
|
||||
"NATIVE: testing the tuple? function"
|
||||
(assert-false (tuple? [4 5]))
|
||||
(assert-true (tuple? (, 4 5))))
|
||||
|
||||
(defn test-gensym []
|
||||
"NATIVE: testing the gensym function"
|
||||
(import [hy.models [HySymbol]])
|
||||
|
Loading…
Reference in New Issue
Block a user