Lazy Evaluation

Nguyen Phan Dung [email protected]
Mon, 4 Mar 2002 09:55:06 +0800


This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C1C362.AA438E90
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

 

Hello,

 

Sorry for asking such a silly question: Haskell is using lazy
evaluation. So, it means we should be able to declare and use a list of
billions elements without any trouble. So I declare my list as follow:

 

mylist :: [Integer]

mylist = [1..1000000000]

 

In Hugs, I type mylist to print out all the elements inside. However,
after printing about 22000 elements, the system crashs & outputs:
"Garbage collection fails to reclaim sufficient memory"

 

Would you please help me with this problem?

Thank you very much,

Phan Dung.


------=_NextPart_000_0001_01C1C362.AA438E90
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html>

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">


<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">

<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:VNI-Times;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{font-family:VNI-Times;
	color:blue;
	font-weight:normal;
	font-style:normal;
	text-decoration:none none;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>&nbsp;</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>Hello,</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>&nbsp;</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>Sorry for =
asking such
a silly question: Haskell is using lazy evaluation. So, it means we =
should be
able to declare and use a list of billions elements without any trouble. =
So I declare
my list as follow:</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>&nbsp;</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>mylist :: =
[Integer]</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>mylist =3D
[1..1000000000]</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>&nbsp;</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>In Hugs, I =
type mylist
to print out all the elements inside. However, after printing about =
22000
elements, the system crashs &amp; outputs: &#8220;Garbage collection =
fails to
reclaim sufficient memory&#8221;</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>&nbsp;</span>=
</font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>Would you =
please help
me with this problem?</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>Thank you =
very much,</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dblue face=3DVNI-Times><span
style=3D'font-size:12.0pt;font-family:VNI-Times;color:blue'>Phan =
Dung.</span></font></p>

</div>

</body>

</html>

------=_NextPart_000_0001_01C1C362.AA438E90--