[Haskell-cafe] Re: Function to cast types
lemming at henning-thielemann.de
Sun Mar 22 19:36:17 EDT 2009
On Sun, 22 Mar 2009, Achim Schneider wrote:
> Anonymous Anonymous <temp.public at gmail.com> wrote:
>> I'm new to haskell, I'm wondering how can you write a function that
>> will do the following:
>> fromIntToString :: Int -> String
>> this is a cast function to cast an Int to a String. I know such
>> function exist, however let's assume it didn't exist. How would I
>> write such function?
> I have no Idea, but this one works:
> intOfChar c | c >= '0' && c <= '9' = fromEnum c - fromEnum '0'
> intOfChar _ = undefined
this is 'digitToInt' from Char module
More information about the Haskell-Cafe