Added name and keyword functions to core
This commit is contained in:
parent
7fe997e9f7
commit
a49047b7a3
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
(import [hy._compat [long-type]]) ; long for python2, int for python3
|
(import [hy._compat [long-type]]) ; long for python2, int for python3
|
||||||
(import [hy.models.cons [HyCons]]
|
(import [hy.models.cons [HyCons]]
|
||||||
[hy.models.keyword [HyKeyword KEYWORD_PREFIX]])
|
[hy.models.keyword [HyKeyword *keyword-prefix*]])
|
||||||
|
|
||||||
|
|
||||||
(defn _numeric-check [x]
|
(defn _numeric-check [x]
|
||||||
@ -359,7 +359,7 @@
|
|||||||
(defn keyword [value]
|
(defn keyword [value]
|
||||||
"Create a keyword from the given value. Strings numbers and even objects
|
"Create a keyword from the given value. Strings numbers and even objects
|
||||||
with the __name__ magic will work"
|
with the __name__ magic will work"
|
||||||
(if (and (string? value) (value.startswith KEYWORD_PREFIX))
|
(if (and (string? value) (value.startswith *keyword-prefix*))
|
||||||
(hyify value)
|
(hyify value)
|
||||||
(if (string? value)
|
(if (string? value)
|
||||||
(HyKeyword (+ ":" (hyify value)))
|
(HyKeyword (+ ":" (hyify value)))
|
||||||
@ -370,7 +370,7 @@
|
|||||||
(defn name [value]
|
(defn name [value]
|
||||||
"Convert the given value to a string. Keyword special character will be stripped.
|
"Convert the given value to a string. Keyword special character will be stripped.
|
||||||
String will be used as is. Even objects with the __name__ magic will work"
|
String will be used as is. Even objects with the __name__ magic will work"
|
||||||
(if (and (string? value) (value.startswith KEYWORD_PREFIX))
|
(if (and (string? value) (value.startswith *keyword-prefix*))
|
||||||
(hyify (slice value 2))
|
(hyify (slice value 2))
|
||||||
(if (string? value)
|
(if (string? value)
|
||||||
(hyify value)
|
(hyify value)
|
||||||
|
Loading…
Reference in New Issue
Block a user