AppleScript名:連番数値リスト中で欠落アイテム(Gap)を抽出 v2 |
— Created 2017-12-06 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html property SMSForder : a reference to current application’s SMSForder property NSIndexSet : a reference to current application’s NSIndexSet property NSMutableSet : a reference to current application’s NSMutableSet property NSMutableArray : a reference to current application’s NSMutableArray load framework set aList to {1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 20} set aRes to calcGaps(aList) of me –> {19, 13} on calcGaps(aList as list) set nArray to (NSMutableArray’s arrayWithArray:aList) set maxRes to (nArray’s valueForKeyPath:"@max.self")’s intValue() set minRes to (nArray’s valueForKeyPath:"@min.self")’s intValue() –最小値から最大値までの連番リスト作成 set theIndexSet to NSIndexSet’s indexSetWithIndexesInRange:{minRes, maxRes} set theList to (SMSForder’s arrayWithIndexSet:theIndexSet) as list –補集合 set aSet to NSMutableSet’s setWithArray:theList set bSet to NSMutableSet’s setWithArray:nArray aSet’s minusSet:bSet return aSet’s allObjects() as list end calcGaps |
More from my site
(Visited 36 times, 1 visits today)