[Haskell-beginners] Re: Time interval calculation
uzytkownik2 at gmail.com
Sat Mar 13 22:21:21 EST 2010
On Sat, 2010-03-13 at 21:20 +0100, legajid wrote:
> 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?
Haskell calculates the expression when it needs. So
let t1 = last (listeprem 5000)
Means rather 't1 is expression ....' then calculate .... and save result
in t1. evaluate is a nice function that forces the evaluation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20100313/9fb84440/attachment.bin
More information about the Beginners