In the olden lisp days, reduce was often preferred to apply because apply could hit limits on the number of arguments that could be passed to a function. Is that a potential issue with clojure?
Thanks, John On Wed, Feb 12, 2014 at 12:06 PM, Vincent <vhenneb...@gmail.com> wrote: > On Wednesday, February 12, 2014 2:47:07 PM UTC, Stuart Sierra wrote: >> >> On Wednesday, February 12, 2014 8:46:41 AM UTC-5, Vincent wrote: >>> >>> On a slightly different topic: why reduce and not apply? >>> >> >> The implementation of `+` with more than 2 arguments uses `reduce` >> internally. So they amount to the same thing. >> > > Ah ok, interesting. I do seem to have, in the past, come across a function > that was significantly faster when used with apply rather than reduce, but > I can't remember which one. > > > >> There isn't really a performance difference: >> >> user=> (dotimes [i 7] (time (reduce + (range 10000000)))) >> "Elapsed time: 354.475 msecs" >> "Elapsed time: 346.235 msecs" >> "Elapsed time: 348.124 msecs" >> "Elapsed time: 348.894 msecs" >> "Elapsed time: 379.9 msecs" >> "Elapsed time: 356.337 msecs" >> "Elapsed time: 362.788 msecs" >> nil >> user=> (dotimes [i 7] (time (apply + (range 10000000)))) >> "Elapsed time: 360.067 msecs" >> "Elapsed time: 353.281 msecs" >> "Elapsed time: 345.694 msecs" >> "Elapsed time: 355.162 msecs" >> "Elapsed time: 346.511 msecs" >> "Elapsed time: 350.61 msecs" >> "Elapsed time: 353.674 msecs" >> nil >> > > Thanks, > Vincent > > -- > 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 this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.