Re: minimum function?
Re: minimum function?
- Subject: Re: minimum function?
- From: Adam Wuellner <email@hidden>
- Date: Tue, 5 Apr 2005 17:40:56 -0500
On 5 Apr 2005, at 21:40, Mark J. Reed wrote:
> No need to do that; what happens if all the values are > 2^512?
> Unlikely, but not impossible. :)
> Just start out with it set to the first one and loop through the rest:
>
> on min(theList)
> set minVal to theList's item 1
> repeat with i from 2 to count theList
> if theList's item i < minVal then
>
set minVal to theList's item i
> end if
> end repeat
> return minVal
> end min
On Apr 5, 2005 3:53 PM,
Rob Stott <
email@hidden> wrote:
I'm confused about why this script doesn't fall over with a 'list'
containing just one item though.
It looks like the kind of thing that might cause an error,
but AS is content to just skip over the repeat block when the range
(coupled with the increment) doesn't make any sense:
repeat with i from 2 to 1
-- by default, i is incremented by 1 in each iteration
log i
end repeat
log "Hello"
The above will log (*Hello*) only.
repeat with i from 2 to 1 by -1
log i
end repeat
log "Hello"
The above logs (*2*), (*1*), and (*Hello*).
Just the way it works.
- Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden