On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes
<cguimaraes...@gmail.com> wrote:
> I hava a list (a b c) and want to create a hashmap using the elements from
> this list.
>
> The keys will be a sequential number, and the values will be the values from
> the previous list.
>
> 1. list:
>   (a b c)
>
> 2. desired hashmap:
>   (hash-map 1 "a" 2 "b" 3 "c")
>
> How can I achieve this in a idiomatic functional way?

And now for something completely different:

    > ([1 2 3] 0)
    1
    > ([1 2 3] 1)
    2

I refer, of course, to the strange property of vectors in that they
are also functions of their index. So if you it's cool for you to have
the list be a vector and the access to be vector first then 'key',
then you need to write no code whatsoever.

--

Timmy V.

http://twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to