lazy Printing question
David Roundy
droundy@abridgegame.org
Mon, 21 Jul 2003 08:36:42 -0400
On Mon, Jul 21, 2003 at 05:41:32PM +0530, AJ wrote:
> Hi everyone,
Hi!
> I have written the following program to find "magic numbers"
> i.e. integers 'n' such that both (n+1) and (n/2+1) are perfect squares.
>
> Import IO
>
> main :: IO ()
> main =
> do
> print (filter magicP sqs)
> Now my question is - How do I reproduce such "lazy printing" behaviour in
> GHC?
My guess would be to try running
main = putStr $ unlines $ map show $ filter magicP sqs
It may be that print is doing something like checking the length of the
list which would of course not allow for lazy printing.
--
David Roundy
http://www.abridgegame.org