On Sun, Oct 7, 2012 at 3:53 PM, Alan Malloy <
al...@malloys.org> wrote:
> This is nonsense. If s is fixed-size at compile-time, you would never use
> apply to begin with. Why bother with (applyn 10 + [1 2 3 4 5 6 7 8 9 10])
> when you could just write (+ 1 2 3 4 5 6 7 8 9 10)?
Why bother to write (+ 1 2 3 4 5 6 7 8 9 10) when you could just write 55?
In order to write (+ 1 2 3 4 5 6 7 ...) you need more than just the
length of the list, you need to know its contents as well.
(let [s (take 10 (infinite-stream-of-random-integers))] (applyn 10 + s))
will work right---you know the length of s---but you're not going to
be able to just directly apply +.
I'm skeptical for a different reason:
user=> (let[t(fn[](apply + '(1 2 3 4 5 6 7 8 9 10)))]
(time(dotimes [_ 1000000] (t))))
"Elapsed time: 1736.91518 msecs"
nil
user=> (let[t(fn[](applyn 10 + '(1 2 3 4 5 6 7 8 9 10)))]
(time(dotimes [_ 1000000] (t))))
"Elapsed time: 2375.503756 msecs"
nil
--
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]