2012-11-11 79 views

回答

2

當列表中僅包含字符串,並且不包含換行,如可以使用更快的方法,當兩個列表包含上千項adayzdone示例代碼。

--NOTE: Only works with lists containing strings and not containing linefeeds. 
set listA to {"A1", "A2", "A3"} 
set listB to {"B1", "B2", "A3"} 

set AppleScript's text item delimiters to linefeed 
set newList to every paragraph of (do shell script "sort -fu <<< " & quoted form of ((listA as string) & linefeed & listB as string)) 
set AppleScript's text item delimiters to "" 

return newList 
+0

我以前沒見過! +1 – adayzdone

1

嘗試:

set listA to {"A1", "A2", "A3"} 
set listB to {"B1", "B2", "A3"} 

repeat with anItem in listB 
    if anItem is not in listA then 
     set end of listA to contents of anItem 
    end if 
end repeat 

return listA 
相關問題