I have a handler that checks and adds a list (contains string only) to a list of list if it does not already exist in the list of list. This time, I am not dealing with a large number of items. I am just wondering if there is a better way to code.
Thanks
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set theMainListOfList to {{"a", "b"}, {"c", "d"}}
set theNewList to {"a", "b"}
addNewItemToLOL(theNewList, theMainListOfList)
-- return {{"a", "b"}, {"c", "d"}}
set theNewList to {"a", "c"}
addNewItemToLOL(theNewList, theMainListOfList)
-- return {{"a", "b"}, {"c", "d"}, {"a", "c"}}
on addNewItemToLOL(theL, theLOL)
set theTransformedLOL to {}
repeat with each in theLOL
set end of theTransformedLOL to each as text
end repeat
if theTransformedLOL contains (theL as text) then
else
set end of theLOL to theL
end if
end addNewItemToLOL
([quote] tags changed to [applescript] by NG.)