
On 9/17/07, Peter Verswyvelen
Maybe this is a stupid question, but I don't find something similar in Haskell.
I find mod and rem, which work on integers. But I'm looking for a function similar to C's fmod.
Of course I can write it myself, but I guess it must already exist under a different name?
This one worried me for a while but, help is at hand with the std library. In Prelude there is a function properFraction which splits a RealFrac into its integer part and its fractional part. You can use this to implement fmod. Assuming properFraction is efficient (which it probably isn't), you can implement fmod really quite efficiently. In particular, x `fmod` 1.0 == (snd . properFraction) x cheers, T. -- Thomas Conway drtomc@gmail.com Silence is the perfectest herald of joy: I were but little happy, if I could say how much.