On Tue, 05 May 2009 09:39:21 +0200
Christophe Grand wrote:
>
> Kevin Downey a écrit :
> > (into {} (apply map vector
> > '((cars bmw chevrolet ford peugeot)
> > (genres adventure horror mystery
> >
> > {ford mystery, chevrolet horror, bmw adventure, cars ge
Kevin Downey a écrit :
> (into {} (apply map vector
> '((cars bmw chevrolet ford peugeot)
> (genres adventure horror mystery
>
> {ford mystery, chevrolet horror, bmw adventure, cars genres}
>
or:
user=> (apply zipmap '((cars bmw chevrolet ford peugeot) (ge
(into {} (apply map vector
'((cars bmw chevrolet ford peugeot)
(genres adventure horror mystery
{ford mystery, chevrolet horror, bmw adventure, cars genres}
On Mon, May 4, 2009 at 4:03 PM, Michel S. wrote:
>
>
>
> On May 4, 5:07 pm, Christophe Grand wrote
On May 4, 5:07 pm, Christophe Grand wrote:
> Michel S. a écrit :
>
> >> (apply conj {} (map split-kv (split-pairs test-str)))
>
> > The last can be simplified by using into:
> > (into {} (map split-kv (split-pairs test-str)))
>
> It should be noted that into (and conj) is somewhat tricky with m
Michel S. a écrit :
>> (apply conj {} (map split-kv (split-pairs test-str)))
>>
>>
> The last can be simplified by using into:
> (into {} (map split-kv (split-pairs test-str)))
>
It should be noted that into (and conj) is somewhat tricky with maps:
user=> (into {} '({1 2} {3 4}))
{3 4, 1
On May 4, 9:03 am, Konrad Hinsen wrote:
> On May 4, 2009, at 14:23, Nathan Hawkins wrote:
>
> > This seems a little bit more like what I expected:
>
> > (map-assoc split-kv (split-pairs test-str))
>
> > -> {"baz" "3", "bar" "2", "foo" "1"}
>
> > Am I overlooking some already existing function h
On Mon, 04 May 2009 16:31:21 +0200
Christophe Grand wrote:
>
> Nathan Hawkins a écrit :
> > Ok, my example seems to have misled. You're missing the point a
> > little bit:
> >
> > 1. I was trying to avoid the (reduce conj {} ...), by having the map
> > function do it. Why even build a list that
Nathan Hawkins a écrit :
> Ok, my example seems to have misled. You're missing the point a little
> bit:
>
> 1. I was trying to avoid the (reduce conj {} ...), by having the map
> function do it. Why even build a list that's only going to get thrown
> away when I want a hash-map at the end?
>
> 2.
On Mon, 4 May 2009 16:07:06 +0200
Christopher Taylor wrote:
>
> Hi Nathan,
>
> On 04.05.2009, at 15:47, Nathan Hawkins wrote:
>
> >
> > On Mon, 4 May 2009 06:16:14 -0700 (PDT)
> > Drew Raines wrote:
> >>
> >> Whoops, that (seq) is a debugging artifact. You can remove that:
> >>
> >> (let [t
On May 4, 8:05 am, Drew Raines wrote:
> user> (let [test-str "foo=1;bar=2;baz=3"]
> (reduce conj {}
> (map #(apply hash-map (seq (.split % "=")))
> (.split test-str ";"
Whoops, that (seq) is a debugging artifact. You can remove that:
(let [test-str "foo=1
On May 4, 7:23 am, Nathan Hawkins wrote:
> Possibly I'm going about this wrong. I'm trying to understand how best
> to construct maps from sequences, by applying a function which returns a
> key / value pair.
>
> Something like this:
>
> (ns test (:use clojure.contrib.str-utils))
>
> (def test-
Hi Nathan,
On 04.05.2009, at 15:47, Nathan Hawkins wrote:
>
> On Mon, 4 May 2009 06:16:14 -0700 (PDT)
> Drew Raines wrote:
>>
>> Whoops, that (seq) is a debugging artifact. You can remove that:
>>
>> (let [test-str "foo=1;bar=2;baz=3"]
>> (reduce conj {}
>> (map #(apply hash-map (.sp
On Mon, 4 May 2009 06:16:14 -0700 (PDT)
Drew Raines wrote:
>
> On May 4, 8:05 am, Drew Raines wrote:
>
> > user> (let [test-str "foo=1;bar=2;baz=3"]
> > (reduce conj {}
> > (map #(apply hash-map (seq (.split % "=")))
> > (.split test-str ";"
>
> Whoops,
2009/5/4 Nathan Hawkins :
>
> Possibly I'm going about this wrong. I'm trying to understand how best
> to construct maps from sequences, by applying a function which returns a
> key / value pair.
>
> Something like this:
>
> (ns test (:use clojure.contrib.str-utils))
>
> (def test-str "foo=1;bar=2
Nathan Hawkins wrote:
> Possibly I'm going about this wrong. I'm trying to understand how
> best to construct maps from sequences, by applying a function which
> returns a key / value pair.
[...]
> Am I overlooking some already existing function hidden away someplace
> that does this?
Here's
On May 4, 2009, at 14:23, Nathan Hawkins wrote:
> This seems a little bit more like what I expected:
>
> (map-assoc split-kv (split-pairs test-str))
>
> -> {"baz" "3", "bar" "2", "foo" "1"}
>
>
> Am I overlooking some already existing function hidden away someplace
> that does this?
Here's one w
Possibly I'm going about this wrong. I'm trying to understand how best
to construct maps from sequences, by applying a function which returns a
key / value pair.
Something like this:
(ns test (:use clojure.contrib.str-utils))
(def test-str "foo=1;bar=2;baz=3")
(defn split-kv [text]
(let [[k
17 matches
Mail list logo