[Haskell-beginners] Time interval calculation
daniel.is.fischer at web.de
Sat Mar 13 15:50:19 EST 2010
Am Samstag 13 März 2010 21:42:12 schrieb legajid:
> 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.
Right, that's not so good.
> 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 ?
Depends on the types. Often a bang-pattern or a `seq` is enough, for other
types, you might want to look at Control.DeepSeq and
Control.Parallel.Strategies. NFData, rnf, deepseq, using, demanding, ...
may help you. For lists, sometimes (length list) `seq` whatever is enough,
without needing strategies.
More information about the Beginners