summaryrefslogtreecommitdiff
path: root/gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-04-07 00:49:19 +0300
committerPaul Buetow <paul@buetow.org>2023-04-07 00:49:19 +0300
commit30fc4e8f74315a92aaec36dfb9a8d4efa0a21791 (patch)
tree97ef2b26fd54a366d72f5289ba11ea311f8a0173 /gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html
parent5c9e3886de0f9041e4a6fb6fea9917e29a8fbd76 (diff)
exact style
Diffstat (limited to 'gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html')
-rw-r--r--gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html44
1 files changed, 30 insertions, 14 deletions
diff --git a/gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html b/gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html
index 4a98a243..0d56577d 100644
--- a/gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html
+++ b/gemfeed/2010-05-07-lazy-evaluation-with-standarn-ml.html
@@ -8,8 +8,10 @@
<link rel="stylesheet" href="style-override.css" />
</head>
<body>
-<h1>Lazy Evaluation with Standard ML</h1>
-<p class="quote"><i>Published at 2010-05-07T08:17:59+01:00</i></p>
+<h1 style='display: inline'>Lazy Evaluation with Standard ML</h1><br />
+<br />
+<span class=quote>Published at 2010-05-07T08:17:59+01:00</span><br />
+<br />
<pre>
_____|~~\_____ _____________
@@ -22,12 +24,19 @@
`---------------'--\\\\ .`--' -Glyde-
`||||
</pre>
-<p>In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation. </p>
-<a class="textlink" href="https://en.wikipedia.org/wiki/Eager_evaluation">https://en.wikipedia.org/wiki/Eager_evaluation</a><br />
-<a class="textlink" href="https://en.wikipedia.org/wiki/Lazy_evaluation">https://en.wikipedia.org/wiki/Lazy_evaluation</a><br />
-<p>You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier.</p>
-<h2>Emulating lazy evaluation in SML</h2>
-<p>However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements):</p>
+<br />
+<span>In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation. </span><br />
+<br />
+<a class=textlink href='https://en.wikipedia.org/wiki/Eager_evaluation'>https://en.wikipedia.org/wiki/Eager_evaluation</a><br />
+<a class=textlink href='https://en.wikipedia.org/wiki/Lazy_evaluation'>https://en.wikipedia.org/wiki/Lazy_evaluation</a><br />
+<br />
+<br />
+<span>You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier.</span><br />
+<br />
+<h2 style='display: inline'>Emulating lazy evaluation in SML</h2><br />
+<br />
+<span>However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements):</span><br />
+<br />
<pre>
type ’a lazy = unit -&gt; ’a;
@@ -67,9 +76,13 @@ fun nat_pairs_not_null () =
val test = first 10 (nat_pairs_not_null ());
*)
</pre>
-<a class="textlink" href="http://smlnj.org/">http://smlnj.org/</a><br />
-<h2>Real laziness with Haskell </h2>
-<p>As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version. </p>
+<br />
+<a class=textlink href='http://smlnj.org/'>http://smlnj.org/</a><br />
+<br />
+<h2 style='display: inline'>Real laziness with Haskell </h2><br />
+<br />
+<span>As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version. </span><br />
+<br />
<pre>
{- Just to make it look like the ML example -}
first = take
@@ -91,9 +104,12 @@ nat_pairs_not_null = filters (\[x,y] -&gt; x &gt; 0 &amp;&amp; y &gt; 0) nat_pai
first 10 nat_pairs_not_null
-}
</pre>
-<a class="textlink" href="http://www.haskell.org/">http://www.haskell.org/</a><br />
-<p>E-Mail your comments to hi@paul.cyou :-)</p>
-<a class="textlink" href="../">Back to the main site</a><br />
+<br />
+<a class=textlink href='http://www.haskell.org/'>http://www.haskell.org/</a><br />
+<br />
+<span>E-Mail your comments to hi@paul.cyou :-)</span><br />
+<br />
+<a class=textlink href='../'>Back to the main site</a><br />
<p class="footer">
Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter</a> |
served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |