• 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: minimum function?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: minimum function?


  • Subject: Re: minimum function?
  • From: Rob Stott <email@hidden>
  • Date: Tue, 5 Apr 2005 21:53:29 +0100

Spooky... that's almost what I said... ;-)

I'm confused about why this script doesn't fall over with a 'list' containing just one item though.

r.


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

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
  • Follow-Ups:
    • Re: minimum function?
      • From: Adam Wuellner <email@hidden>
References: 
 >minimum function? (From: Jake Pietrykowski <email@hidden>)
 >Re: minimum function? (From: jj <email@hidden>)
 >Re: minimum function? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: minimum function?
  • Next by Date: Re: Folder Actions Dictionary
  • Previous by thread: Re: minimum function?
  • Next by thread: Re: minimum function?
  • Index(es):
    • Date
    • Thread