add list?
function to hy.core
`list?` will test if the argument is an instance of list.
This commit is contained in:
parent
cbca711865
commit
b0ed103931
1
NEWS.rst
1
NEWS.rst
@ -11,6 +11,7 @@ New Features
|
|||||||
------------------------------
|
------------------------------
|
||||||
* Format strings with embedded Hy code (e.g., `f"The sum is {(+ x y)}"`)
|
* Format strings with embedded Hy code (e.g., `f"The sum is {(+ x y)}"`)
|
||||||
are now supported, even on Pythons earlier than 3.6.
|
are now supported, even on Pythons earlier than 3.6.
|
||||||
|
* New list? function.
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
------------------------------
|
------------------------------
|
||||||
|
@ -899,6 +899,24 @@ Returns the first logically-true value of ``(pred x)`` for any ``x`` in
|
|||||||
True
|
True
|
||||||
|
|
||||||
|
|
||||||
|
.. _list?-fn:
|
||||||
|
|
||||||
|
list?
|
||||||
|
-----
|
||||||
|
|
||||||
|
Usage: ``(list? x)``
|
||||||
|
|
||||||
|
Returns ``True`` if *x* is a list.
|
||||||
|
|
||||||
|
.. code-block:: hy
|
||||||
|
|
||||||
|
=> (list? '(inc 41))
|
||||||
|
True
|
||||||
|
|
||||||
|
=> (list? '42)
|
||||||
|
False
|
||||||
|
|
||||||
|
|
||||||
.. _string?-fn:
|
.. _string?-fn:
|
||||||
|
|
||||||
string?
|
string?
|
||||||
|
@ -203,6 +203,9 @@ Return series of accumulated sums (or other binary function results)."
|
|||||||
"Check if x is float."
|
"Check if x is float."
|
||||||
(isinstance x float))
|
(isinstance x float))
|
||||||
|
|
||||||
|
(defn list? [x]
|
||||||
|
(isinstance x list))
|
||||||
|
|
||||||
(defn symbol? [s]
|
(defn symbol? [s]
|
||||||
"Check if `s` is a symbol."
|
"Check if `s` is a symbol."
|
||||||
(instance? HySymbol s))
|
(instance? HySymbol s))
|
||||||
@ -454,7 +457,7 @@ Even objects with the __name__ magic will work."
|
|||||||
disassemble drop drop-last drop-while empty? eval even? every? exec first
|
disassemble drop drop-last drop-while empty? eval even? every? exec first
|
||||||
filter flatten float? fraction gensym group-by identity inc input instance?
|
filter flatten float? fraction gensym group-by identity inc input instance?
|
||||||
integer integer? integer-char? interleave interpose islice iterable?
|
integer integer? integer-char? interleave interpose islice iterable?
|
||||||
iterate iterator? juxt keyword keyword? last macroexpand
|
iterate iterator? juxt keyword keyword? last list? macroexpand
|
||||||
macroexpand-1 mangle map merge-with multicombinations name neg? none? nth
|
macroexpand-1 mangle map merge-with multicombinations name neg? none? nth
|
||||||
numeric? odd? partition permutations pos? product range read read-str
|
numeric? odd? partition permutations pos? product range read read-str
|
||||||
remove repeat repeatedly rest reduce second some string string? symbol?
|
remove repeat repeatedly rest reduce second some string string? symbol?
|
||||||
|
@ -267,6 +267,11 @@ result['y in globals'] = 'y' in globals()")
|
|||||||
(assert-true (symbol? 'im-symbol))
|
(assert-true (symbol? 'im-symbol))
|
||||||
(assert-false (symbol? (name 'im-symbol))))
|
(assert-false (symbol? (name 'im-symbol))))
|
||||||
|
|
||||||
|
(defn test-list? []
|
||||||
|
"NATIVE: testing the list? function"
|
||||||
|
(assert-false (list? "hello"))
|
||||||
|
(assert-true (list? [1 2 3])))
|
||||||
|
|
||||||
(defn test-gensym []
|
(defn test-gensym []
|
||||||
"NATIVE: testing the gensym function"
|
"NATIVE: testing the gensym function"
|
||||||
(import [hy.models [HySymbol]])
|
(import [hy.models [HySymbol]])
|
||||||
|
Loading…
Reference in New Issue
Block a user