Re: minimum function?
Re: minimum function?
- Subject: Re: minimum function?
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 5 Apr 2005 16:40:34 -0400
#################################
> set theList to {5, 4, 2, 6}
>
> set min to 2 ^ 512 --> very high value
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
Then you can call that anywhere else in your code like so:
set smallest to min({5,8,17,23,6});
_______________________________________________
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