On Apr 3, 2005, at 9:04 PM, Ken Ray wrote:
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.
I took a break and tried my hand at this.
The function using offset did better than array element deletion in some cases. The function using replaceText() did poorly for medium size lists and bailed out for large lists to be removed. I think there is something fishy (that is n^2) in replaceText(). The last one was my attempt to avoid 'line n' and is similar to Frank's, I think. It was still a little bit slower than array element deletion in my tests.
function shortListDar2 pList, pExcludeList
local resultList = ""
put lf before pList
put 0 into lastUsedChar
if char -1 of pList is not lf then put lf after pList
repeat for each line ex in pExcludeList
put lf & ex & lf into exWithLF
get offset(exWithLf,pList,lastUsedChar)
if it is not zero then
put char lastUsedChar+1 to lastUsedChar+it of pList after resultList
put lastUsedChar + it + length(exWithLF) - 1 into lastUsedChar
end if
end repeat
put char lastUsedChar+1 to -1 of pList after resultList
return char 2 to -2 of resultList
end shortListDar2
--function shortListDar3 pList, pExcludeList -- get "(?m)^" & replaceText(pExcludeList,"\n","\n|^") & "\n" -- return replaceText(pList,it,empty) --end shortListDar3
function shortListDar4 pList, pExcludeList
local resultList
put lf & "10000000000000" after pExcludeList
put line 1 of pExcludeList into checkLine
put 1 into charOffset
repeat for each line listLine in pList
repeat while checkLine < listLine
add length(checkLine)+1 to charOffset
put line 1 of (char charoffset to charoffset+20 of pExcludeList) into checkLine
end repeat
if listLine < checkline then
put listLine & lf after resultList
end if
end repeat
return char 1 to -2 of resultList
end shortListDar4
--
**********************************************
DSC (Dar Scott Consulting & Dar's Lab)
http://www.swcp.com/dsc/
Programming Services and Software
**********************************************
_______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
