How to get the difference between two lists?
Monte Goulding
monte at sweattechnologies.com
Sun Apr 3 23:30:40 EDT 2005
> I've got two lists - one with is the "comprehensive" list that is
> return-delimited, like:
>
> 3
> 5
> 6
> 7
> 11
> 14
> 18
> 21
>
> And another list which is the list I would like to *remove* from the
> comprehensive list:
>
> 5
> 6
> 11
> 18
>
> Which should give me:
>
> 3
> 7
> 14
> 21
>
> I can of course do a repeat loop through the small list and remove those
> items from the comprehensive list, but I'm wondering if there's a faster
> way
> to do this. The numbers will always be sorted in ascending numeric order,
> but there may be thousands of them, so I'm not looking forward to a repeat
> loop.
How about:
split the long list into an array
loop over the short list
delete array elements for each line of the short list
combine the long list
resort the long list
Should be faster than deleting a line in the middle of a long list but I
could be wrong.
It's a pity we don't have an inverse of the intersect command.
Cheers
Monte
More information about the use-livecode
mailing list