Filtering one list out of another

Paul Hibbert paulhibbert at mac.com
Mon Dec 23 21:19:16 EST 2013


If they are only short lists there's the simple approach…

function filterList pListA pListB
   repeat for each line i in pListB
      delete line lineOffset(i,pListA) of pListA
   end repeat
   return pListA
end filterList

…or am I missing something?

Paul

On 2013-12-23, at 3:50 PM, Devin Asay <devin_asay at byu.edu> wrote:

> 
> On Dec 23, 2013, at 4:24 PM, Dick Kriesel wrote:
> 
>> Hi, Devin.  Here's a version that uses arrays for speed.	
>> 
>> command difference @rList1, @rList2
>>   local tArray1, tArray2
>>   repeat for each line tLine in rList2
>>       put "true" into tArray2[ tLine ]
>>   end repeat
>>   repeat for each line tLine in rList1
>>       if not tArray2[ tLine ] then
>>           put "true" into tArray1[ tLine ]
>>       end if
>>   end repeat
>>   put the keys of tArray1 into rList1
>> end difference
> 
> Clever approach. Thanks, Dick.
> 
> Devin
> 
> Devin Asay
> Learn to code with LiveCode University
> http://university.livecode.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





More information about the use-livecode mailing list