
22 Mar
2011
22 Mar
'11
4:46 a.m.
OK I did this: import System.Random walk :: Int -> IO Int walk i = randomRIO (0,1) >>= \r -> return (i+r*2-1) say :: Int -> IO () say i = putStrLn $ show i rep :: Int -> a -> (a -> IO a) -> (a -> IO ()) -> IO () rep n i w s | n<=0 = return () | otherwise = s i >> w i >>= \ii -> rep (n-1) ii w s main :: IO () main = rep 10 50 walk say Is that the easiest way? Adrian.