On Aug 23, 5:21 pm, Stan Dyck <[email protected]> wrote:
> I'm still new to this so bear with me.
>
> I'm trying to apply a function to a seq-able thing to produce a hashmap. So
> for instance say the function is (inc 3).
> I'd like to write a function that does
>
> [1 2 3] --> {1 4, 2 5, 3 6}
>
> Can someone help me?
>
> StanD.
There may be a cleaner solution, but this works:
(defn build-map [s fun]
(apply hash-map (interleave s (map fun s))))
=> (build-map [1 2 3] inc)
{1 2, 2 3, 3 4}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---