Re: Implementation of zipmap

2009-10-31 Thread Dex Wood
If that is the case, it could be implemented using transients for a performance increase. On Oct 30, 10:53 am, Alex Osborne wrote: > Chouser wrote: > > On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: > >> John Harrop wrote: > >>> Was something wrong with this?: > > >>> (defn my-zipmap > >

Re: Implementation of zipmap

2009-10-30 Thread Alex Osborne
Chouser wrote: > On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: >> John Harrop wrote: >>> Was something wrong with this?: >>> >>> (defn my-zipmap >>> "Returns a map with the keys mapped to the corresponding vals." >>> [keys vals] >>> (into {} (map vec (partition 2 (interleave keys va

Re: Implementation of zipmap

2009-10-30 Thread Chouser
On Fri, Oct 30, 2009 at 11:44 AM, John Harrop wrote: > On Fri, Oct 30, 2009 at 11:37 AM, Chouser wrote: >> >> On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: >> > >> > John Harrop wrote: >> >> Was something wrong with this?: >> >> >> >> (defn my-zipmap >> >>   "Returns a map with the keys

Re: Implementation of zipmap

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 11:37 AM, Chouser wrote: > On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: > > > > John Harrop wrote: > >> Was something wrong with this?: > >> > >> (defn my-zipmap > >> "Returns a map with the keys mapped to the corresponding vals." > >> [keys vals] > >> (int

Re: Implementation of zipmap

2009-10-30 Thread Chouser
On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: > > John Harrop wrote: >> Was something wrong with this?: >> >> (defn my-zipmap >>   "Returns a map with the keys mapped to the corresponding vals." >>   [keys vals] >>   (into {} (map vec (partition 2 (interleave keys vals) >> >> :) > > O

Re: Implementation of zipmap

2009-10-30 Thread Alex Osborne
John Harrop wrote: > Was something wrong with this?: > > (defn my-zipmap > "Returns a map with the keys mapped to the corresponding vals." > [keys vals] > (into {} (map vec (partition 2 (interleave keys vals) > > :) One reason might be that the original zipmap is 5-10 times faster for

Implementation of zipmap

2009-10-30 Thread John Harrop
What's up with this? (defn zipmap "Returns a map with the keys mapped to the corresponding vals." [keys vals] (loop [map {} ks (seq keys) vs (seq vals)] (if (and ks vs) (recur (assoc map (first ks) (first vs)) (next ks) (nex