指定のリストから削除指定リストに入っているアイテムを削除する

指定のリストから、「削除指定リスト」に入っているアイテムを削除するAppleScriptです。

削除指定リストには、何アイテム目のリスト項目を削除するかを指定しておきます。ほとんど組み捨てレベルのAppleScriptで、何度書いたか覚えていませんが……とりあえず。

スクリプト名:指定のリストから削除指定リストに入っているアイテムを削除する
set deleteList to {1, 3, 5} –削除アイテムリスト
set aList to {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5}} –元リスト

set aRes to deleteItemfromListByDelList(aList, deleteList) of me
–> {{2, 2, 2}, {4, 4, 4}}–元リストから削除アイテムリストをもとに削除を行った結果

–指定のリストから削除指定リストに入っているアイテムを削除する
on deleteItemfromListByDelList(aList, deleteList)
  
  
set itemCounter to 1
  
set newList to {}
  
  
repeat with i in aList
    set j to contents of i
    
if itemCounter is not in deleteList then
      set the end of newList to j
    end if
    
set itemCounter to itemCounter + 1
  end repeat
  
  
return newList
end deleteItemfromListByDelList

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

Leave a Reply