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
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
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
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
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
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
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
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
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
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") #"
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
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.
>
>
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
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
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
15 matches
Mail list logo