• 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: Tue, 14 Sep 2010 12:40:18 -0500

FWIW, here's my "not terribly elegant" solution that I wrote yesterday.

For paranoia's sake, I used copy, but I'm sure a set will do the trick.

Please feel free to modify to your heart's content.

Cheers, 
- Alex

on GetMinimum(myList)
if myList = {} then return
set myMinimum to missing value
repeat with myItem in myList
if myItem < myMinimum or myMinimum = missing value then copy myItem to myMinimum
end repeat
return myMinimum
end GetMinimum

on GetMaximum(myList)
if myList = {} then return
set myMaximum to missing value
repeat with myItem in myList
if myItem > myMaximum or myMaximum = missing value then copy myItem to myMaximum
end repeat
return myMaximum
end GetMaximum
 _______________________________________________
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: "Nigel Garvey" <email@hidden>)
 >Re: Getting the maximum value and minimal values in a list (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: Re: Getting file suffix
  • Next by Date: InDesign CS4 Script Question
  • Previous by thread: Re: Getting the maximum value and minimal values in a list
  • Next by thread: Applescript: force garbage collection? (NSAppleScript call from Cocoa app)
  • Index(es):
    • Date
    • Thread