Re: How to convert this list into map?

2014-05-10 Thread Mike Fikes
That looks much better IMHO :) -- 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

Re: How to convert this list into map?

2014-05-10 Thread Stephen Gilardi
As a slight simplification you can take advantage of the fact that apply handles in-line arguments as well as a seq of arguments at the end. This also works: user=> (apply hash-map :op '(:= :language "Clojure")) {:op :=, :language "Clojure"} --Steve On May 10, 2014, at 6:37 PM, Hussein B. wro

Re: How to convert this list into map?

2014-05-10 Thread Hussein B.
That is beautiful! Thanks a lot! On Sunday, May 11, 2014 12:33:51 AM UTC+2, Mike Fikes wrote: > > Here is how you can derive that expression: > > {:op :=, :language "Clojure"} > > is the same as > > (hash-map :op := :language "Clojure") > > > which is the same as > > (apply hash-map '(:op := :lang

Re: How to convert this list into map?

2014-05-10 Thread Mike Fikes
Here is how you can derive that expression: {:op :=, :language "Clojure"} is the same as (hash-map :op := :language "Clojure") which is the same as (apply hash-map '(:op := :language "Clojure")) So, all you need is '(:op := :language "Clojure") which can be produced by prepending :op to y

Re: How to convert this list into map?

2014-05-10 Thread Mike Fikes
user=> (apply hash-map (conj '(:= :language "Clojure") :op)) {:op :=, :language "Clojure"} On Saturday, May 10, 2014 5:56:59 PM UTC-4, Hussein B. wrote: > > Hi, > > I have this list: > > (:= :language "Clojure") > > And I want to convert it to the following map data structure: > > {:op := , :la

How to convert this list into map?

2014-05-10 Thread Hussein B.
Hi, I have this list: (:= :language "Clojure") And I want to convert it to the following map data structure: {:op := , :language "Clojure"} I can't really think of a clear way how to do it. Would you please help? Thanks for help and time. -- You received this message because you are subscr

Re: (newbie) - first question - split list of maps into map of maps based on distinct values

2011-11-09 Thread Colin Yates
Sometimes the answer is just too simple: group-by (see the last post on http://stackoverflow.com/questions/3052162/coverting-a-vector-of-maps-to-map-of-maps-in-clojure) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

(newbie) - first question - split list of maps into map of maps based on distinct values

2011-11-09 Thread Colin Yates
Hi all, So finally I have managed to get to write some clojure. Gotta say, after two days I am seriously excited - talk about removing ceremony and focusing on the issue. I feel like a blind man performing surgery with welding gloves on whilst holding this tiny but unbelievably powerful and myst

Re: into map with vectors versus lists (Re: Creating map from string)

2010-12-24 Thread Emeka
unately, `into' doesn't seem to allow pushing lists of pairs > into a map. But vectors are allowed: > > (into {} (map vec (partition 2 (split (slurp "data") #"," > > Can somebody explain why vectors are allowed and lists not? > > > On 2010/1

into map with vectors versus lists (Re: Creating map from string)

2010-12-04 Thread Remco van 't Veer
I expected this to work: (into {} (partition 2 (split (slurp "data") #","))) But unfortunately, `into' doesn't seem to allow pushing lists of pairs into a map. But vectors are allowed: (into {} (map vec (partition 2 (split (slurp "data") #"

Re: into map?

2010-02-16 Thread Meikel Brandmeyer
Hi, On Feb 17, 4:19 am, Mark Engelberg wrote: > dotimes is for side effects. As a rule of thumb: everything starting with "do" is related to side effects. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: into map?

2010-02-16 Thread Base
2 things about Clojure 1. It amazes me how easy it is to get things done 2. The Clojure Group members are fantastic! Thanks guys!! On Feb 16, 10:19 pm, Mark Engelberg wrote: > dotimes is for side effects.  What you want is to use a for loop that > produces a sequence of key-value pairs. > >

Re: into map?

2010-02-16 Thread Mark Engelberg
dotimes is for side effects. What you want is to use a for loop that produces a sequence of key-value pairs. (into {} (for [i (range 3)] [i (range 4)])) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: into map?

2010-02-16 Thread Timothy Pratley
On 17 February 2010 13:55, Base wrote: > {  0 [ 01 2 3] , >   1 [0 1 2 3] , >   2 [0 1 2 3] } > > and want to do something like > (defn create-map [] >    (into {} (dotimes [x 2] (assoc x (range 4) (zipmap (range 3) (repeat 3 (range 4))) -- You received this message because you are subscri

into map?

2010-02-16 Thread Base
Hi All, I am struggling with inserting items into a map. I would like to create a function that would create a map that would look like { 0 [ 01 2 3] , 1 [0 1 2 3] , 2 [0 1 2 3] } and want to do something like (defn create-map [] (into {} (dotimes [x 2] (assoc x (range 4) but t