On Oct 10, 2014, at 1:46 PM, Ben Wolfson <wolf...@gmail.com> wrote: > it's not quite at compile-time (since it's a dynamic call to eval, after all, > and "names" and "headers" aren't known at compile time), but it is calling it > eval-time, for lack of a better phrase.
Yes, I meant when it compiles the code that eval executes at, er, run-time :) Sean > On Fri, Oct 10, 2014 at 1:35 PM, Sean Corfield <s...@corfield.org> wrote: > Ah, interesting... I hadn't considered it was running the zipmap at > compile-time so it only runs it once as opposed to running it for each row! > > Sean > > On Oct 10, 2014, at 1:06 PM, Ben Wolfson <wolf...@gmail.com> wrote: > > I believe it's because the `mapper` function is just creating and returning > > a map literal. The "mapper" function in the evaled version is something > > like this: > > > > user> (def names '[n1 n2 n3 n4]) > > #'user/names > > user> (def headers '[h1 h2 h3 h4]) > > #'user/headers > > user> `(fn [[~@names]] ~(zipmap headers names)) > > (clojure.core/fn [[n1 n2 n3 n4]] {h4 n4, h3 n3, h2 n2, h1 n1}) ;; just a > > map literal, whose keys are already known. > > > > Whereas in the first version, zipmap has to be called, iterating over > > headers and names each time. >
signature.asc
Description: Message signed with OpenPGP using GPGMail