Yoshinori Kohyama <yykohy...@gmail.com> writes: >> But still my reverse-the-collection-and-then-reduce-it approach is >> still much faster, although it has to iterate the collection twice. > > It seems to make things faster using a '(transient [])'. Thank you.
The main difference is that I build up a new vector of functions instead of a list of functions in order not to have to reverse it. I just tried without the transient (i.e., a plain persistent vector), and it doesn't really change the timings. So I'd conclude that building up a new vector is cheap in comparison to the function allocations. >> I'm not exactly sure why, but I'd guess the allocation overhead for 2 >> million partial functions is rather expensive. > > Allocation of partial functions is expensive as you say. May it be > that 'conj'ing an element at the last of a collection still takes much > cost than 'cons'ing an element at the head of it and reversing? No, for vectors conjoining to the tail is the most efficient "add"-operation. Consing to a list is probably a bit more efficient, but consing and then reversing is surely not. > I'll keep thinking and trying. Great, I really enjoy your solutions. Bye, Tassilo -- 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