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:
(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
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,
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
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,
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
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
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
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.
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
10 matches
Mail list logo