Menu

Skip to content
AppleScript Hole
  • Home
  • Products
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScript Hole

Useful & Practical AppleScript & AppleScriptObjC archive

2D Listをアイテム数でフィルタリングする

Posted on 4月 9 by Takaaki Naganoya
AppleScript名:2D Listをアイテム数でフィルタリングする
— Created 2018-04-09 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {{"1"}, {"2", "2"}, {"3", "3", "3"}, {"4", "4", "4", "4"}, {"5", "5", "5", "5", "5"}, {"6", "6", "6", "6", "6", "6"}, {"7", "7", "7", "7", "7", "7", "7"}, {"8", "8", "8", "8", "8", "8", "8", "8"}}
set minItemNum to 7
set itemRes1 to retFilterItemMinNum(aList, minItemNum) of me
–> {{"7", "7", "7", "7", "7", "7", "7"}, {"8", "8", "8", "8", "8", "8", "8", "8"}}

set itemRes2 to retFilterItemEquNum(aList, minItemNum) of me
–> {{"7", "7", "7", "7", "7", "7", "7"}}

set itemRes3 to retFilterItemMaxNum(aList, minItemNum) of me
–> {{"1"}, {"2", "2"}, {"3", "3", "3"}, {"4", "4", "4", "4"}, {"5", "5", "5", "5", "5"}, {"6", "6", "6", "6", "6", "6"}, {"7", "7", "7", "7", "7", "7", "7"}}

on retFilterItemMinNum(aList, minItemNum)
  set anArray to current application’s NSMutableArray’s arrayWithArray:aList
  
set predStr to "SELF[SIZE] >= " & (minItemNum as string)
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat:predStr
  
set t2Array to (anArray’s filteredArrayUsingPredicate:aPredicate) as list
  
return t2Array
end retFilterItemMinNum

on retFilterItemEquNum(aList, minItemNum)
  set anArray to current application’s NSMutableArray’s arrayWithArray:aList
  
set predStr to "SELF[SIZE] = " & (minItemNum as string)
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat:predStr
  
set t2Array to (anArray’s filteredArrayUsingPredicate:aPredicate) as list
  
return t2Array
end retFilterItemEquNum

on retFilterItemMaxNum(aList, minItemNum)
  set anArray to current application’s NSMutableArray’s arrayWithArray:aList
  
set predStr to "SELF[SIZE] <= " & (minItemNum as string)
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat:predStr
  
set t2Array to (anArray’s filteredArrayUsingPredicate:aPredicate) as list
  
return t2Array
end retFilterItemMaxNum

★Click Here to Open This Script 

Please follow and like us:
Posted in list | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

電子書籍をBOOTH.pmほかで販売中!!

アーカイブ

  • 2018年4月
  • 2018年3月
  • 2018年2月

カテゴリー

  • AirDrop
  • AirPlay
  • Bluetooth
  • boolean
  • Calendar
  • Clipboard
  • Color
  • dialog
  • drive
  • file
  • File path
  • filter
  • folder
  • geolocation
  • GUI
  • Icon
  • Image
  • Internet
  • Keychain
  • list
  • Markdown
  • Menu
  • Network
  • Number
  • OSA
  • PDF
  • Record
  • regexp
  • Require Control-Command-R to run
  • REST API
  • RTF
  • Screen Saver
  • shell script
  • Sound
  • Spotlight
  • System
  • Text
  • Time Zone
  • URL
  • UTI
  • WiFi
  • XML-RPC
  • 未分類

メタ情報

  • 登録
  • ログイン
  • 投稿の RSS
  • コメントの RSS
  • WordPress.org

Tags

10.11savvy (864) 10.12savvy (868) 10.13savvy (864) AirServer (2) App Store (1) Calendar (3) CotEditor (27) Dictionary (9) Dock (7) Evernote (2) Finder (14) Font (4) HelpViewer (2) iBooks (1) Input Method (4) iTunes (12) JeditΩ (3) Keynote (10) Language (1) Locale (3) Mac Blu-ray Player (1) MacDown (2) Mail (6) Maps (3) Numbers (8) Pages (2) Printer (1) QuickTime Player (8) Safari (12) Script Debugger (1) Script Editor (7) Sorting (5) Spell check (3) Spellchecker (3) System Events (5) Terminal (4) TextEdit (12) Text To Speech (7) Timezone (5) Twitter (1)

Forum Posts

  • 人気のトピック
  • 返信がないトピック





Proudly powered by WordPress
Theme: Flint by Star Verte LLC

Enjoy this blog? Please spread the word :)

  • RSS
  • Follow by Email
  • Facebook
  • Google+
    http://piyocast.com/as/archives/3064">
  • Twitter