Jump to content

Unique characters: Difference between revisions

Added AppleScript.
(Added AppleScript.)
Line 13:
{{Template:Strings}}
<br><br>
 
=={{header|AppleScript}}==
The filtering here is case sensitive, the sorting dependent on locale.
 
<lang applescript>use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
use framework "Foundation"
 
on uniqueCharacters(listOfStrings)
set countedSet to current application's class "NSCountedSet"'s new()
repeat with thisString in listOfStrings
tell countedSet to addObjectsFromArray:(thisString's characters)
end repeat
set mutableSet to current application's class "NSMutableSet"'s setWithSet:(countedSet)
tell countedSet to minusSet:(mutableSet)
tell mutableSet to minusSet:(countedSet)
set sortDescriptor to current application's class "NSSortDescriptor"'s sortDescriptorWithKey:("self") ¬
ascending:(true) selector:("localizedStandardCompare:")
return (mutableSet's sortedArrayUsingDescriptors:({sortDescriptor})) as list
end uniqueCharacters
 
return uniqueCharacters({"133252abcdeeffd", "a6789798st", "yxcdfgxcyz"})</lang>
 
{{output}}
<lang applescript>{"1", "5", "6", "b", "g", "s", "t", "z"}</lang>
 
=={{header|Factor}}==
557

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.