[Haskell-cafe] Haskell-Newbie and Char-Function

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Dec 5 14:46:04 EST 2009

On Sat, Dec 5, 2009 at 4:48 PM, Jochem Berndsen <jochem at functor.nl> wrote:
> MeAdAstra wrote:
>> Hi guys,
>> I only started learning Haskell some days ago. Maybe one of you can give me
>> a hint on how to implement a function that needs a character in the range
>> (a,b,...z) and an integer number k and returns the k-next neighbor of the
>> character? For example, fct a 5 would result in output f.
> You might want to use the functions ord and chr from Data.Char, and the
> mod function from the Prelude.

Right, and by the way I would suggest you reverse the parameter order
of your function so that it takes the shift first, then you can write

> shift :: Int -> Char -> Char
> shift n c ...
> rot13 :: String -> String
> rot13 = map (shift 13)


More information about the Haskell-Cafe mailing list