On Wed, Nov 26, 2008 at 9:29 AM, peg <[EMAIL PROTECTED]> wrote:
>
> I wanted to transform string keys to keyword key so I coded that
> thing ;-) :
>
> (defn string2keyword [mapWithStringsAsKeys]
>    (apply hash-map
>        (mapcat (fn [_] (list (keyword (first _)) (frest _))) 
> mapWithStringsAsKeys)))
>
> ; mapcat  (1) apply fn to create (:key val) then (2) concat and (3)
> apply hashmap creates the new map
>
> is there a shorter way or a clojure fn to do that ?

(defn string2keyword [in-map]
  (into {} (for [[k v] in-map] [(keyword k) v])))

That's essentially the same algorithm.  I don't think there's a
built-in function to do it for you.

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to