• 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: Get position of item in list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get position of item in list


  • Subject: Re: Get position of item in list
  • From: Joseph Weaks <email@hidden>
  • Date: Wed, 25 Jun 2003 15:15:53 -0500

On Wednesday, June 25, 2003, at 02:34 PM, Kai wrote:

on Tue, 24 Jun 2003 21:53:31 -0500, Joseph Weaks <email@hidden> wrote:

These have all been some very wordy solutions.

Hey - we're doin' our best here! (Besides, if my original 6-line, tid-based
handler is "wordy", how would you describe your 9-line loop handler?) ;-
)
...
On the other hand, testing of this kind can be extremely time consuming. So
if you're just looking for a general handler that you can use in various
situations, Paul S's advice makes a lot of sense.
...
If you're fairly confident that the list will generally contain the search
string, then you'll get a speed advantage from this form:

====================

on getPosition(i, l)
repeat with n from 1 to (count l)
if l's item n starts with i then return n
end repeat
0
end getPosition

====================

--
Kai

Thanks, Kai. I'm always amazed at how streamlined some of you experienced programmers can get code. I liked the offset option as well, but I don't know of a way to get it to adhere to an "ignoring case" block. I completely agree with you and Paul S., that it's not worth the time trying to benchmark methods... I guess my question was basically, "What would be the broad cut off when a repeat loop really begins to lose out against a tid method?"
Thanks again to everyone for the great ideas on this issue.
Joe Weaks
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Get position of item in list
      • From: Walter Purvis <email@hidden>
References: 
 >Re: Get position of item in list (From: Kai <email@hidden>)

  • Prev by Date: Re: Projects/Instruction Suitable for an 11 yr. old?
  • Next by Date: Re: tab delimited data file
  • Previous by thread: Re: Get position of item in list
  • Next by thread: Re: Get position of item in list
  • Index(es):
    • Date
    • Thread