Replies: 4 comments 5 replies
-
The constructor for => (hy.models.Keyword "hello")
:hello |
Beta Was this translation helpful? Give feedback.
-
Thank you! I extended it to take a nested dictionary. Is there something like this already?
|
Beta Was this translation helpful? Give feedback.
-
no there's not. It's generally discouraged in Hy to use keywords as dict keys. Hy is much much closer to Python than clojure is to java and Python generally expects strings as keys. In addition we use keywords for keyword args and the dict constructor produces string keys => (:hello {"hello" 1})
1
=> (:hello (dict :hello 1))
1 You should generally think of Hy as lispy Python and not a completely separate language. i.e. your solution could also be solved (defn keywordize [coll]
(dfor [k v] (.items coll)
:setv value (if (isinstance v dict) (keywordize v) v)
:setv key (if (isinstance k Keyword) k (Keyword k))
[key value])) |
Beta Was this translation helpful? Give feedback.
-
A follow-up question about keywords. I am using hylang to generate
I'd like to write this out to a file. However, any conversion produces this:
How is the |
Beta Was this translation helpful? Give feedback.
-
Is there a function available to perform this operation?
https://github.com/borkdude/jet
Beta Was this translation helpful? Give feedback.
All reactions