
2 Feb
2006
2 Feb
'06
2:08 p.m.
On 2/2/06, MaurĂcio
I understand those examples, but I really would like to know how to do that with monads. I would like to ask the same question, but now with this code:
double a = 1000; double b = 0; while (a != b) { a /= 2; cout << a; // Prints a cin << b; // User gives a number, stored in b };
An idiomatic approach: example :: Double -> Double -> IO () example a b | a == b = return () | otherwise = do let a' = a / 2 print a' b' <- readLn example a' b' main = example 1000 0