Quickest was to compare 2 CR lists?
briany at qldlearning.com
Tue Nov 4 03:53:45 CST 2008
Something like this should work, using arrays. Basically you just
"mark" off each line in k2, and then go through k1 checking if they
were marked. Since arrays are fast and you only have to pass through
each list once w/o ever going back to the start, this should be much
faster than lineOffset() which searches the whole list each time.
repeat for each line tLine in k2
put 1 into tArray[tLine]
repeat for each line tLine in k1
if (tArray[tLine] = 1) then put tLine&cr after newList
return char 1 to -2 of newList
> Hi all,
> anyone knows the quickest ways to compare 2 CR delimited lists?
> I need to know what lines of list 1 are contained in list 2.
> Right now I am using repeat "for each" and "lineoffset", which is
> but I'm ure this can be done even faster :-)
> List 1 = k1
> List 2 = k2
> repeat for each line i in k1
> if lineoffset(i,k2) <> 0 then
> put i & CR after new_ list
> end if
> end repeat
> delete char -1 of new_ list
> return new_ list
> Klaus Major
> klaus at major-k.de
More information about the use-livecode