Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion apply: increase performance by 60% for fixed length
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ben Wolfson  
View profile  
 More options Oct 7 2012, 10:56 pm
From: Ben Wolfson <wolf...@gmail.com>
Date: Sun, 7 Oct 2012 19:56:45 -0700
Local: Sun, Oct 7 2012 10:56 pm
Subject: Re: apply: increase performance by 60% for fixed length

On Sun, Oct 7, 2012 at 3:53 PM, Alan Malloy <a...@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]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.