solidabis-koodihaaste/src/Data/Caesar.hs

18 lines
288 B
Haskell
Raw Normal View History

2019-10-15 19:53:38 +03:00
module Data.Caesar where
2019-10-15 20:22:31 +03:00
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)