On Fri, Oct 30, 2009 at 11:44 AM, John Harrop <[email protected]> wrote:
> On Fri, Oct 30, 2009 at 11:37 AM, Chouser <[email protected]> wrote:
>>
>> On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne <[email protected]> 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)))))
>> >>
>> >> :)
>> >
>> > One reason might be that the original zipmap is 5-10 times faster for
>> > large numbers of entries as it doesn't create all the temporary seqs.
>>
>> Another might be that into, partition and interleave don't exist
>> yet when zipmap is defined.
>
> Eh. Implementation details.
I thought that's what we were discussing: the implementation
and its details. :-)
> That got me to poke in the source for into and:
> (def
> #^{:arglists '([coll x] [coll x & xs])
> :doc "conj[oin]. Returns a new collection with the xs
> 'added'. (conj nil item) returns (item). The 'addition' may
> happen at different 'places' depending on the concrete type."}
> conj (fn conj
> ([coll x] (. clojure.lang.RT (conj coll x)))
> ([coll x & xs]
> (if xs
> (recur (conj coll x) (first xs) (next xs))
> (conj coll x)))))
> This is especially odd: the two-argument case appears to call itself
> recursively to get the argument for a Java call.
That's the old-style interop syntax playing tricks on you.
(. clojure.lang.RT (conj coll x))
is the same as
(clojure.lang.RT/conj coll x)
--Chouser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---