18 lines
288 B
Haskell
18 lines
288 B
Haskell
module Data.Caesar where
|
|
|
|
type Caesar = Char
|
|
|
|
next :: Char -> Char
|
|
next c =
|
|
case c of
|
|
'.' -> '.'
|
|
' ' -> ' '
|
|
'ö' -> 'ä'
|
|
'ä' -> 'å'
|
|
'å' -> 'z'
|
|
'a' -> 'ö'
|
|
x -> pred x
|
|
|
|
caesar :: Int -> Caesar -> Caesar
|
|
caesar n x = foldr ($) x (replicate n next)
|