[Haskell-cafe] Fractional Part

2011-08-02 Thread Ata Jafari
Hi everyone, I'm totally new to Haskell and functional programming. I try to solve some problems from Proejct Euler with Haskell so that I can improve myself in functional programming. In the first step I want to write a little code that can give me only the decimal part of a float. For

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Chris Smith
On Wed, 2011-08-03 at 02:06 +0300, Ata Jafari wrote: In the first step I want to write a little code that can give me only the decimal part of a float. For instance: properFraction from the RealFrac type class will divide into the real and fractional parts. Once you've got the fractional

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Mark Spezzano
Hi Ata, You could write the following decimalPart :: Float - Integer decimalPart f = read (tail (tail (show (f :: Integer This basically says convert f into a String using the show function, and then get the tail of that String twice to get rid of the leading zero and the decimal point

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Eric Rasmussen
Just a hint, but with Project Euler there's a chance you're headed in a difficult direction if you're working with the decimal parts directly. Usually (always?) you can approach the problem in a way that won't depend on something like decimal precision that can be different across