September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,7 +1,14 @@
import Data.Char
import Data.Char (isAlpha, toLower, chr, ord)
rot13 :: Char -> Char
rot13 c
| toLower c >= 'a' && toLower c <= 'm' = chr (ord c + 13)
| toLower c >= 'n' && toLower c <= 'z' = chr (ord c - 13)
| isAlpha c = chr (if_ (toLower c <= 'm') (+) (-) (ord c) 13)
| otherwise = c
if_ :: Bool -> a -> a -> a
if_ True x _ = x
if_ False _ y = y
-- Simple test
main :: IO ()
main = print $ rot13 <$> "Abjurer nowhere"