Merge branch 'master' into pr/975
This commit is contained in:
commit
6ea6777663
@ -436,6 +436,26 @@ themselves as an iterator when ``(iter x)`` is called. Contrast with
|
|||||||
=> (iterator? (iter {:a 1 :b 2 :c 3}))
|
=> (iterator? (iter {:a 1 :b 2 :c 3}))
|
||||||
True
|
True
|
||||||
|
|
||||||
|
.. _keyword-fn:
|
||||||
|
|
||||||
|
keyword
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. versionadded:: 0.10.1
|
||||||
|
|
||||||
|
Usage: ``(keyword "foo")``
|
||||||
|
|
||||||
|
Create a keyword from the given value. Strings, numbers, and even
|
||||||
|
objects with the `__name__` magic will work.
|
||||||
|
|
||||||
|
.. code-block:: hy
|
||||||
|
|
||||||
|
=> (keyword "foo")
|
||||||
|
u'\ufdd0:foo'
|
||||||
|
|
||||||
|
=> (keyword 1)
|
||||||
|
u'\ufdd0:1'
|
||||||
|
|
||||||
.. _keyword?-fn:
|
.. _keyword?-fn:
|
||||||
|
|
||||||
keyword?
|
keyword?
|
||||||
@ -536,6 +556,24 @@ calling ``(f val-in-result val-in-latter)``.
|
|||||||
{u'a': 11L, u'c': 30L, u'b': 20L}
|
{u'a': 11L, u'c': 30L, u'b': 20L}
|
||||||
|
|
||||||
|
|
||||||
|
.. _name-fn:
|
||||||
|
|
||||||
|
name
|
||||||
|
----
|
||||||
|
|
||||||
|
.. versionadded:: 0.10.1
|
||||||
|
|
||||||
|
Usage: ``(name :keyword)``
|
||||||
|
|
||||||
|
Convert the given value to a string. Keyword special character will be
|
||||||
|
stripped. Strings will be used as is. Even objects with the `__name__`
|
||||||
|
magic will work.
|
||||||
|
|
||||||
|
.. code-block:: hy
|
||||||
|
|
||||||
|
=> (name :foo)
|
||||||
|
u'foo'
|
||||||
|
|
||||||
.. _neg?-fn:
|
.. _neg?-fn:
|
||||||
|
|
||||||
neg?
|
neg?
|
||||||
|
@ -556,10 +556,21 @@ characters that soon):
|
|||||||
=> #↻(1 2 3 +)
|
=> #↻(1 2 3 +)
|
||||||
6
|
6
|
||||||
|
|
||||||
Macros are useful when one wished to extend the Hy or write their own
|
Macros are useful when one wishes to extend the Hy or write their own
|
||||||
language on top of that. Many features of Hy are macros, like ``when``,
|
language on top of that. Many features of Hy are macros, like ``when``,
|
||||||
``cond`` and ``->``.
|
``cond`` and ``->``.
|
||||||
|
|
||||||
|
To use macros defined in a different module, it is not enough to
|
||||||
|
``import`` the module, because importing happens at run-time, while we
|
||||||
|
would need macros at compile-time. Instead of importing the module
|
||||||
|
with macros, it must be ``require``d:
|
||||||
|
|
||||||
|
.. code-block:: clj
|
||||||
|
|
||||||
|
=> (require tutorial.macros)
|
||||||
|
=> (rev (1 2 3 +))
|
||||||
|
6
|
||||||
|
|
||||||
Hy <-> Python interop
|
Hy <-> Python interop
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user