How to get the difference between two lists?

Brian Yennie briany at qldlearning.com
Mon Apr 4 02:07:33 EDT 2005


Ken,

What kind of database? You might be able to keep these operations 
in-database, depending on what the tables/ needs are.

For example:

SELECT recID FROM someTable WHERE (recID IN (3,5,6,7,11,14,18,21)) AND 
NOT (recID IN (5,6,11,18))

It's a little kludgey using the above, but keeping the work in-database 
somewhere might give you good results.
The database delete of course could be something like:

DELETE FROM someTable WHERE recID IN (5,6,11,18);

Dunno if that springs an idea or works- but most database engines will 
work through long lists of recIDs very fast. If you can get the results 
as a side effect of queries you need to make anyway, all the better.

One other idea:

repeat for each line l in (tOriginalList&cr&tRemoveList)
    if (tArray[l] is not empty) then delete tArray[l]
    else put l into tArray[l]
end repeat
combine tArray

This is off the top of my head, but the idea is: combine the lists and 
pass through once. If you already saw an item, it must need to be 
deleted (so empty the array item). Otherwise, just pop it into the 
array. Combine when done.

IOW- combine them and delete anything with a duplicate.

HTH!

Brian

> On 4/3/05 11:24 PM, "simplsol at aol.com" <simplsol at aol.com> wrote:
>
>> Ken,
>> Would it help to
>> 1. mark cards that need to be removed
>> 2. sort by marked cards
>> 3. delete the marked cards
>> Still a repeat loop, but each card would not have to be evaluated
>> during the loop.
>
> Well, the problem is that it is not cards I'm dealing with but lists of
> numbers (record IDs) that are returned from database calls.
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>



More information about the use-livecode mailing list