[Haskell-beginners] Time interval calculation
legajid at free.fr
Sat Mar 13 15:42:12 EST 2010
After a few efforts, i've understood my mistake.
I now write :
t1d <- gettime
putStrLn ("Methode 1 : " ++ show t1d)
let t1=last (listeprem 5000)
putStrLn (" " ++ show t1)
t1f <- gettime
putStrLn (" " ++ show t1f)
and that's ok.
What i feel shocking is having io code mixed within calculation code.
I think it's possible to force calculation of t1d, t1 and t1f before
(or without) displaying their values (i just want t1f - t1d).
But how to make it ?
legajid a écrit :
> my following code should show time before executing listeprem, then
> time after execution.
> import System.Time
> gettime :: IO ClockTime
> gettime = getClockTime
> t1d <- gettime
> let t1=last (listeprem 5000)
> t1f <- gettime
> putStrLn ("Methode 1 : " ++ show t1d)
> putStrLn (" " ++ show t1)
> putStrLn (" " ++ show t1f)
> Looking at the screen, t1d is displayed then, after a few seconds, t1
> and t1f.
> But, t1d and t1f are equal.
> It seems like if t1d and t1f where calculated at start of procedure,
> before we need calculating t1 for putStrLn.
> How can i have t1f evaluated after t1, so i can calculate time elapsed
> for calculation of t1?
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners