Filtering array vs plain list
Shari
shari at gypsyware.com
Sat Feb 2 10:49:11 EST 2008
> personName[3258] = "Billy Bob"
> birthyear[3258] = 1982
>
>Intersecting the values you get from retrieving each array/key combo gives
>you the identifiers for all the people who match all your selection
>criteria, as many as you care to specify.
I've just about got it. You gave me a good jumping board, Dick.
Here's where it sits. Using one single array (this allows for the
best ease of use), data is stored as follows:
census[1111,team] = Red Sox
census[2222,team] = Red Sox
census[3333,team] = White Sox
census[1111,city] = Chicago
census[2222,city] = Atlanta
census[3333,city] = Chicago
Now, to get a list of folks that live in Atlanta that are Red Sox
fans, I did the following:
put census into a
combine a with return and comma
filter a with "*,team,Red Sox"
put census into b
combine b with return and comma
filter b with "*,city,Atlanta"
This gives me:
a =
1111,team,Red Sox
2222,team,Red Sox
b =
2222,city,Atlanta
Can a and b be intersected as is? (My attempts failed.) The
following works beautifully, but is it the most efficient? Is using
split/combine/filter to manipulate a giant array faster than a repeat
loop thru a gigantic list?
split a by return and comma
split b by return and comma
intersect a with b
combine a with return and comma
answer a
a =
2222,team,Red Sox
That gave me exactly what I need. A list of anyone with team(Red
Sox) and city(Atlanta) with item 1 of each line as the unique
identifier.
Any efficiency suggestions are welcome :-)
Shari
--
WlND0WS and MAClNT0SH shareware games
BIackjack GoId
http://www.gypsyware.com
More information about the use-livecode
mailing list