solidabis-koodihaaste/src/Data/Caesar.hs
2019-10-15 20:22:31 +03:00

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)