Find index of list to find item in another list
Find index of list to find item in another list
- Subject: Find index of list to find item in another list
- From: Jim Skibbie <email@hidden>
- Date: Wed, 01 Jul 2009 10:09:22 -0500
- Thread-topic: Find index of list to find item in another list
Title: Find index of list to find item in another list
I have a task where I need to compare one list of values with another. The lists are quite large, so I’m wondering if there’s any way to not have to loop over the entire list to find the values. For example, I have data that is separated into jobs and related items, so:
123456 has items A, B, C
123457 has item D
123458 has items E, F
I can create this as separate lists like:
--the really big lists
set X to {"123456", "123457", "123458"}
set Y to {{"A", "B", "C"}, {"D"}, {"E", "F"}}
-- the item I'm looking for
set Z to "123457"
I need to know several things about the relationship of “Z” to “X” and “Y”. The first is whether X contains Z. That part seems easy.
X contains Z --> true
But what I really need to know is the index of where in X the value of Z was found (in the example it was the second item) so that I can pick up it’s related information from Y:
item 2 of Y --> {“D”}
Short of iterating through the whole list one at a time, is there a low-level way to get the index number of X where Z is located?
Is there a way to do this more easily with a record instead of a list as I could form the variables for X and Y any way I want?
Thanks.
Jim
_______________________________________________
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