>But I'm wondering if this is the easiest way to do what you want. For
>example, if the two word lists are both return delimited lists, would
>this do what you need?
>
>repeat for each line tWord in tList1
> if tWord is not among the lines of tList2 then
> -- store tWord somewhere
> end if
>end repeat
I'm not sure I understand the problem correctly, but if you want the
words that are in either list, but not both, and if the lists are
guaranteed to contain no duplicates within themselves (put another way,
neither list has two entries in _itself_ that are the same), then the
above should test both lists, by following with:
repeat for each line tWord in tList2
if tWord is not among the lines of tList1 then
-- store tWord somewhere
end if
end repeat
The above is very good for short lists, up about a hundred words. For
larger lists, the following would quickly become much faster, as the
lists grew longer:
put tList1 & return & tList2 into tList --join them into one list
sort lines of tList --sort the combined list
--this assumes no duplicates within either list.
--if duplicates are possble, you would first have to
--filter the lists individually, removing duplicates.
put false into newValue --the test boolean
put "" into oldLine --the stored previous word
put "" into uniqueList --the result
repeat for each line L in tList
if L is not oldLine then --we've hit a different word
if newValue then --if the last line was also different from
--the one before it
put oldLine & return after uniqueList --add it to the result
else
put true into newValue --don't add it, but note that this is
--a new line
end if
put L into oldLine --in any case, change the old line value
else --same as last line
put false into newValue --note that this is a duplicate,
--which will not be put into the result
end if
end repeat
if newValue then --don't forget the last line!
put L after uniqueList --if it's unique, add it to the result
else
delete the last character of uniqueList
--otherwise, just pull out the final return
end if
Hope this helps,
gc
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm