2011/1/23 WoodHacker <[email protected]>
> Is it possible to create a map key from an integer or string to be
> used for retrieving data dynamically from a map?
>
Yes,
but with numbers and Clojure 1.2, be careful to always use the same kind of
"wrapper" (java.lang.Integer or java.lang.Long) or you'll be in trouble:
user=> (def m { "a b c" "first", (Integer. "2") "second", (Long. "3")
"third"})
#'user/m
user=> (get m "a b c")
"first"
user=> (get m (Integer. "2"))
"second"
user=> (get m (Long. "2"))
nil
user=> (get m 2)
"second"
user=> (get m 3)
nil
HTH,
--
Laurent
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en