Re: minimum function?
Re: minimum function?
- Subject: Re: minimum function?
- From: Jake Pietrykowski <email@hidden>
- Date: Tue, 05 Apr 2005 15:33:16 -0500
>> Hi,
>>
>> Does anywhere exist a command for a minimum function? Where x is the
>> returned smallest number of the list {a,b,c}?
>>
>> ex. x = min{a,b,c}
>>
>> Thanks,
>> Jake
>
> There is "statlist" inside Satimage osax:
>
> #################################
> minimum of (statlist {5, 4, 2, 6}) --> 2.0
> #################################
>
> http://www.satimage.fr/software/en/downloads_osaxen.html
>
> You can also loop through the list (depending on the length of the list, it
> will be faster using Satimage):
>
> #################################
> set theList to {5, 4, 2, 6}
>
> set min to 2 ^ 512 --> very high value
>
> repeat with i from 1 to count theList
> if theList's item i < min then set min to theList's item i
> end repeat
>
> min --> 2
> #################################
>
>
> jj
What if all values of my list are larger than 2 ^ 512, then the min result
would in fact be a number not in theList.
I'll get the same result with this, no?
<snip>
set theList to {5, 4, 2, 6}
set min to last item of theList
repeat with i from 1 to count theList
if theList's item i < min then set min to theList's item i
end repeat
</snip>
Thanks for the 1 liner. I never remember to think like this, and get stuck
sorting lists, rather than using a conditional variable.
Thanks,
Jake
_______________________________________________
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