From f73c862ffa65d84a9d485b795e33f0bd0a9e067c Mon Sep 17 00:00:00 2001 From: Csilla Nagyne Martinak Date: Sat, 17 Oct 2015 13:56:35 +0200 Subject: [PATCH] docs: Document the (keyword) and (name) functions Closes #733 Signed-off-by: Csilla Nagyne Martinak --- docs/language/core.rst | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/language/core.rst b/docs/language/core.rst index 58b00d9..b3bb65f 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -436,6 +436,26 @@ themselves as an iterator when ``(iter x)`` is called. Contrast with => (iterator? (iter {:a 1 :b 2 :c 3})) 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? @@ -536,6 +556,24 @@ calling ``(f val-in-result val-in-latter)``. {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?