Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
50
Task/Set/AppleScript/set-1.applescript
Normal file
50
Task/Set/AppleScript/set-1.applescript
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
|
||||
use framework "Foundation"
|
||||
--use scripting additions
|
||||
|
||||
on doSetTask()
|
||||
-- 'set' at the beginnings of lines is an AppleScript command; nothing to do with sets.
|
||||
|
||||
set output to {}
|
||||
set astid to AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to ", "
|
||||
|
||||
set S to current application's class "NSSet"'s setWithArray:({1, 2, 3, 6, 7, 8, 9, 0})
|
||||
set end of output to "Set S: " & (S's allObjects() as list)
|
||||
set end of output to "\"aardvark\" is a member of S: " & ((S's containsObject:("aardvark")) as boolean)
|
||||
set end of output to "3 is a member of S: " & ((S's containsObject:(3)) as boolean)
|
||||
|
||||
|
||||
set A to S's |copy|() -- or: set A to current application's class "NSSet"'s setWithArray:({1, 2, 3, 6, 7, 8, 9, 0})
|
||||
set end of output to linefeed & "Set A: " & (A's allObjects() as list)
|
||||
set B to current application's class "NSSet"'s setWithArray:({2, 2, 2, 3, 4, 5, 6, 7, 7, 7, 8})
|
||||
set end of output to "Set B: " & (B's allObjects() as list)
|
||||
|
||||
set union to A's setByAddingObjectsFromSet:(B)
|
||||
-- Or:
|
||||
-- set union to A's mutableCopy()
|
||||
-- tell union to unionSet:(B)
|
||||
set end of output to "Union of A and B: " & (union's allObjects() as list)
|
||||
|
||||
set intersection to A's mutableCopy()
|
||||
tell intersection to intersectSet:(B)
|
||||
set end of output to "Intersection of A and B: " & (intersection's allObjects() as list)
|
||||
|
||||
set difference to A's mutableCopy()
|
||||
tell difference to minusSet:(B)
|
||||
set end of output to "Difference of A and B: " & (difference's allObjects() as list)
|
||||
|
||||
set end of output to "A is a subset of B: " & ((A's isSubsetOfSet:(B)) as boolean)
|
||||
set end of output to "A is a subset of S: " & ((A's isSubsetOfSet:(S)) as boolean)
|
||||
|
||||
set end of output to "A is equal to B: " & ((A's isEqualToSet:(B)) as boolean)
|
||||
set end of output to "A is equal to S: " & ((A's isEqualToSet:(S)) as boolean)
|
||||
|
||||
set AppleScript's text item delimiters to linefeed
|
||||
set output to output as text
|
||||
set AppleScript's text item delimiters to astid
|
||||
|
||||
return output
|
||||
end doSetTask
|
||||
|
||||
doSetTask()
|
||||
13
Task/Set/AppleScript/set-2.applescript
Normal file
13
Task/Set/AppleScript/set-2.applescript
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"Set S: 0, 9, 1, 6, 2, 7, 3, 8
|
||||
\"aardvark\" is a member of S: false
|
||||
3 is a member of S: true
|
||||
|
||||
Set A: 0, 9, 1, 6, 2, 7, 3, 8
|
||||
Set B: 5, 6, 2, 7, 3, 8, 4
|
||||
Union of A and B: 0, 9, 7, 5, 3, 1, 8, 6, 4, 2
|
||||
Intersection of A and B: 6, 2, 7, 3, 8
|
||||
Difference of A and B: 0, 9, 1
|
||||
A is a subset of B: false
|
||||
A is a subset of S: true
|
||||
A is equal to B: false
|
||||
A is equal to S: true"
|
||||
Loading…
Add table
Add a link
Reference in a new issue