Filtering array vs plain list

Mark Smith mark at maseurope.net
Sat Feb 2 12:35:01 EST 2008


You could try keeping a return-delimited list of all the unique  
individuals in a script local variable "idList", so you could then  
use a repeat loop:

repeat for each line L in idList
  	if census[L,"city"] is "Atlanta" and census[L,"team"] is "Red Sox"  
then put L & cr after tResults
end repeat

I've no idea if this would be faster, but might be worth a try.

Best,

Mark

On 2 Feb 2008, at 15:49, Shari wrote:

>>   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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list