filter?

Dick Kriesel dick.kriesel at mail.com
Thu Jun 23 00:19:57 EDT 2011


On Jun 22, 2011, at 7:30 PM, J. Landman Gay wrote:

> On 6/22/11 9:19 PM, Michael Kann wrote:
>> If you want to use a SORT you can try something like the following:
>> 
>> on mouseUp
>> put "1,2,3,4" into v
>> put "1,2,3,4,5"&  cr before v
>> replace comma with cr in v
>> sort v
>> repeat for each line x in v
>>   if x&  cr&  x is not in v then
>>     put x&  cr after h
>>   end if
>> end repeat
>> put h into fld 3 -- "5"
>> end mouseUp
> 
> That may be faster than the way I was going to do it. I would have done:
> 
> function getUnique pList1,pList2
>  put pList1 & cr & pList2 into tTemp
>  repeat for each line l in tTemp
>    add 1 to array[l]
>  end repeat
>  repeat for each key k in array
>    if array[k] = 1 then put k & cr after tList
>  end repeat
>  return tList
> end getUnique
> 
> But arrays have some overhead. Timing may depend on how long the lists are.
> 
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

Even though it may not always be the fastest, lean code has some appeal: there's no loop.

function intersectionOfLists t1, t2
   split t1 by cr and tab
   split t2 by cr and tab
   intersect t1 with t2
   return the keys of t1
end intersectionOfLists

-- Dick






More information about the use-livecode mailing list