Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Hello all, I'm studying a little bit of Clojure and facing a doubt here. 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:

Re: Creating a hashmap

2012-06-05 Thread Jay Fields
(zipmap (range 1 4) [a b c]) On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes cguimaraes...@gmail.com wrote: Hello all, I'm studying a little bit of Clojure and facing a doubt here. I hava a list (a b c) and want to create a hashmap using the elements from this list. The keys will be

Re: Creating a hashmap

2012-06-05 Thread Jay Fields
Also, if you're looking to learn this kind of stuff, 4clojure.com is an excellent resource. On Tue, Jun 5, 2012 at 8:02 AM, Jay Fields j...@jayfields.com wrote: (zipmap (range 1 4) [a b c]) On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes cguimaraes...@gmail.com wrote: Hello all,

Re: Creating a hashmap

2012-06-05 Thread Ambrose Bonnaire-Sergeant
Or: (zipmap (map inc (range)) '(a b c)) Thanks, Ambrose On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote: (zipmap (range 1 4) [a b c]) On Tue, Jun 5, 2012 at 7:59 AM, Christian Guimaraes cguimaraes...@gmail.com wrote: Hello all, I'm studying a little bit of Clojure

Re: Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Awesome... I'm studying lists manipulation. Solidifying this concept. The basic in Clojure, in my point of view. Thanks again. On Tue, Jun 5, 2012 at 1:03 PM, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Or: (zipmap (map inc (range)) '(a b c)) Thanks, Ambrose On Tue,

Re: Creating a hashmap

2012-06-05 Thread Baishampayan Ghose
Or: (zipmap (drop 1 (range)) '(a b c)) :-) Regards, BG On Tue, Jun 5, 2012 at 5:33 PM, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Or: (zipmap (map inc (range)) '(a b c)) Thanks, Ambrose On Tue, Jun 5, 2012 at 8:02 PM, Jay Fields j...@jayfields.com wrote: (zipmap

Re: Creating a hashmap

2012-06-05 Thread Jay Fields
If I needed the range to be infinite I'd probably use: (zipmap (iterate inc 1) '(a b c)) On Tue, Jun 5, 2012 at 8:13 AM, Baishampayan Ghose b.gh...@gmail.comwrote: Or: (zipmap (drop 1 (range)) '(a b c)) :-) Regards, BG On Tue, Jun 5, 2012 at 5:33 PM, Ambrose Bonnaire-Sergeant

Re: Creating a hashmap

2012-06-05 Thread Meikel Brandmeyer (kotarak)
And a completely different approach: (into {} (map-indexed #(vector (inc %1) %2) [a b c])) Kind regards Meikel -- 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

Re: Creating a hashmap

2012-06-05 Thread Tim Visher
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.

Re: Creating a hashmap

2012-06-05 Thread Christian Guimaraes
Thanks for the tip, Timmy. This is a very interesting Vector feature. -- christian On Tue, Jun 5, 2012 at 7:13 PM, Tim Visher tim.vis...@gmail.com wrote: 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