Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Rot-13/AppleScript/rot-13-1.applescript
Normal file
3
Task/Rot-13/AppleScript/rot-13-1.applescript
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
to rot13(textString)
|
||||
do shell script "tr a-zA-Z n-za-mN-ZA-M <<<" & quoted form of textString
|
||||
end rot13
|
||||
9
Task/Rot-13/AppleScript/rot-13-2.applescript
Normal file
9
Task/Rot-13/AppleScript/rot-13-2.applescript
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
to rot13(textString)
|
||||
set theIDs to id of textString
|
||||
repeat with thisID in theIDs
|
||||
if (((thisID < 123) and (thisID > 96)) or ((thisID < 91) and (thisID > 64))) then ¬
|
||||
tell (thisID mod 32) to set thisID's contents to thisID - it + (it + 12) mod 26 + 1
|
||||
end repeat
|
||||
|
||||
return string id theIDs
|
||||
end rot13
|
||||
1
Task/Rot-13/AppleScript/rot-13-3.applescript
Normal file
1
Task/Rot-13/AppleScript/rot-13-3.applescript
Normal file
|
|
@ -0,0 +1 @@
|
|||
rot13("nowhere ABJURER")
|
||||
61
Task/Rot-13/AppleScript/rot-13-4.applescript
Normal file
61
Task/Rot-13/AppleScript/rot-13-4.applescript
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
-- ROT 13 --------------------------------------------------------------------
|
||||
|
||||
-- rot13 :: String -> String
|
||||
on rot13(str)
|
||||
script rt13
|
||||
on |λ|(x)
|
||||
if (x ≥ "a" and x ≤ "m") or (x ≥ "A" and x ≤ "M") then
|
||||
character id ((id of x) + 13)
|
||||
else if (x ≥ "n" and x ≤ "z") or (x ≥ "N" and x ≤ "Z") then
|
||||
character id ((id of x) - 13)
|
||||
else
|
||||
x
|
||||
end if
|
||||
end |λ|
|
||||
end script
|
||||
|
||||
intercalate("", map(rt13, characters of str))
|
||||
end rot13
|
||||
|
||||
|
||||
-- TEST ----------------------------------------------------------------------
|
||||
on run
|
||||
rot13("nowhere ABJURER")
|
||||
|
||||
--> "abjurer NOWHERE"
|
||||
end run
|
||||
|
||||
|
||||
-- GENERIC FUNCTIONS ---------------------------------------------------------
|
||||
|
||||
-- map :: (a -> b) -> [a] -> [b]
|
||||
on map(f, xs)
|
||||
tell mReturn(f)
|
||||
set lng to length of xs
|
||||
set lst to {}
|
||||
repeat with i from 1 to lng
|
||||
set end of lst to |λ|(item i of xs, i, xs)
|
||||
end repeat
|
||||
return lst
|
||||
end tell
|
||||
end map
|
||||
|
||||
-- intercalate :: Text -> [Text] -> Text
|
||||
on intercalate(strText, lstText)
|
||||
set {dlm, my text item delimiters} to {my text item delimiters, strText}
|
||||
set strJoined to lstText as text
|
||||
set my text item delimiters to dlm
|
||||
return strJoined
|
||||
end intercalate
|
||||
|
||||
-- Lift 2nd class handler function into 1st class script wrapper
|
||||
-- mReturn :: Handler -> Script
|
||||
on mReturn(f)
|
||||
if class of f is script then
|
||||
f
|
||||
else
|
||||
script
|
||||
property |λ| : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
Loading…
Add table
Add a link
Reference in a new issue