• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sum of list?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sum of list?


  • Subject: Re: Sum of list?
  • From: Martin Orpen <email@hidden>
  • Date: Tue, 29 Jun 2004 13:20:25 +0100

on 29/6/04 11:31 am, Emmanuel at email@hidden wrote:

> At 9:15 PM -0400 28/06/04, Graff wrote:
>> I don't know of any implementations of summation algorithms that don't do
>> some sort of iteration in order to sum up a 1-D array (list) of integers.
>
> Before "statlist" existed, I used the following to avoid running a loop:
>
> set theList to {1, 2, 3}
> set theCount to length of theList
> set text item delimiters to "+"
> set theSum to run script "" & theList
> set theAverage to theSum / theCount
>
> (that's faster than the loop, but not much)

That's given me an idea:

set theList to {}
repeat with n from 1 to 2499
set end of theList to n
end repeat
set theCount to length of theList
set text item delimiters to "*"
set theSum to do shell script "echo '" & theList & "' | bc"


Wow, that's a big number - and you don't even have to force the result to be
in "inches" - not an 'E+' in sight.

:-)

--
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.


  • Follow-Ups:
    • Re: Sum of list?
      • From: Emmanuel <email@hidden>
References: 
 >Re: Sum of list? (From: Emmanuel <email@hidden>)

  • Prev by Date: Re: Sum of list?
  • Next by Date: We've been elevated to Gods...
  • Previous by thread: Re: Sum of list?
  • Next by thread: Re: Sum of list?
  • Index(es):
    • Date
    • Thread