Re: Sum of list?
Re: Sum of list?
- Subject: Re: Sum of list?
- From: Martin Orpen <email@hidden>
- Date: Wed, 30 Jun 2004 14:36:30 +0100
on 30/6/04 10:29 am, Emmanuel at email@hidden wrote:
>
At 11:35 PM +0100 29/06/04, Nigel Garvey wrote:
>
> It's possible to write a vanilla 'repeat' equivalent that's just a little
>
> faster than statlist:
>
>
Quite impressive and instructive. I've tested it up to 10,000 numbers - works
>
like a charm.
>
>
This being said, on my old G3/900MHz the vanilla 'repeat' is just a little
>
*slower* than statlist (it requires quite precisely 50% more time: 7
>
microsecond vs 10.5 per item).
If you're working on consecutive numbers you can always use a "Gaussian"
method:
set n to (text returned of (display dialog "Calculate the sum of the
first n integers, where n is:" default answer "")) as number
set x to ((n * (n + 1)) / 2) as inches
display dialog "The sum of the first " & n & " integers is: " & (x as
string)
I doubt that you'd be able to measure the microseconds per item on that one
:-)
--
Martin Orpen
Idea Digital Imaging Ltd -- The Image Specialists
http://www.idea-digital.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.