Re: Too simple to find an answer for...
Re: Too simple to find an answer for...
- Subject: Re: Too simple to find an answer for...
- From: Andrew Oliver <email@hidden>
- Date: Thu, 29 Jul 2004 14:57:19 -0700
Oops, of course :)
Andrew
:)
On 7/29/04 2:21 PM, "Paul Berkowitz" <email@hidden> wrote:
>
That doesn't get the sum, Andrew, that just iterates through the list. The
>
result is the last list item left standing, which is 2. Not what he wants.
>
>
I think you must have intended to do this:
>
>
set MyNumberList to {5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2}
>
>
getSum(MyNumberList)
>
--> 58
>
>
on getSum(theList)
>
set theSum to 0
>
repeat with eachItem in theList
>
try
>
set theSum to theSum + (eachItem as number)
>
end try
>
end repeat
>
return theSum
>
end getSum
>
>
>
Bernardo, by keeping "as number" as Andrew proposes, it will allow you to
>
run the handler of lists of text numbers too, such as {"5", "4", "3", ....}
_______________________________________________
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.