• 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: Getting the maximum value and minimal values in a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the maximum value and minimal values in a list


  • Subject: Re: Getting the maximum value and minimal values in a list
  • From: Alex Zavatone <email@hidden>
  • Date: Mon, 13 Sep 2010 22:44:07 -0500

Nice catch.  I used missing value and put a check in for it myValue = missing value or...

Seems cheesy, but it works.

On Sep 13, 2010, at 9:57 PM, Whit Anderson wrote:

>
> On Sep 13, 2010, at 7:06 PM, email@hidden wrote:
>
>> set list_of_values to {10, 20, 30, 40, 50, 60, 2000, 9, 3000, 4}
>>
>> set minimum to 9.9999999999E+12
>> set maximum to 0
>> repeat with ref_to_value in list_of_values
>> 	set the_value to contents of ref_to_value
>> 	if the_value > maximum then set maximum to the_value
>> 	if the_value < minimum then set minimum to the_value
>> end repeat
>>
>> {minimum, maximum}
>
>
> It seems to me that this will fail if the list contains all negative numbers
>
>
> set list_of_values to {-1, -10, -15}
>
> set minimum to 9.9999999999E+12
> set maximum to 0
> repeat with ref_to_value in list_of_values
> 	set the_value to contents of ref_to_value
> 	if the_value > maximum then set maximum to the_value
> 	if the_value < minimum then set minimum to the_value
> end repeat
>
> {minimum, maximum}
>
> --Whit


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Getting the maximum value and minimal values in a list (From: Whit Anderson <email@hidden>)

  • Prev by Date: Re: Getting the maximum value and minimal values in a list
  • Next by Date: Re: Getting the maximum value and minimal values in a list
  • Previous by thread: Re: Getting the maximum value and minimal values in a list
  • Next by thread: Re: Getting the maximum value and minimal values in a list
  • Index(es):
    • Date
    • Thread