<?xml version='1.0' encoding='iso-8859-1'?><?xml-stylesheet type='text/xsl' href='http://w3future.com/w3f/w3f.xsl' ?>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xf="http://www.w3.org/2002/xforms/cr" xml:lang="en" xml:base="http://w3future.com/weblog/2004/05/13.xml">
<head>
<title>Thursday, May 13, 2004 - Sjoerd Visscher's weblog</title>
<link rel="meta" type="application/rdf+xml" title="FOAF" href="http://w3future.com/people/sjoerd_visscher/foaf.rdf" />
</head>
<body>
<section id="content">
	<h>Sjoerd Visscher's weblog</h>
	<p>Pondering those web technologies that may change the future of the world wide web.</p>
	<section id="note">
		<h>Last Update</h>
		<p>10/16/2005; 1:29:51 AM</p>
		<p id="alternates" class="buttons">
			<l href="http://w3future.com/weblog/2004/05/13.xml?notransform" rel="alternate" type="application/xml" title="See this web page with XHTML 2.0 technology."><span>Try</span> XHTML 2.0</l>
			<l href="view-source:http://w3future.com/weblog/2004/05/13.xml?notransform" title="View the XHTML 2.0 source of this page."><span>Src</span> XHTML 2.0</l>
			<l href="http://w3future.com/tools/xr.pl?xr=http://w3future.com/xr/w3f.xml&amp;xml=http://w3future.com/weblog/2004/05/13.xml%3Fnotransform" rel="meta" type="application/rdf+xml" title="RDF metadata"><span>RDF</span> Metadata</l>
		</p>
		<xi:include href="http://w3future.com/w3f/buttons.xml" />
	</section><section>
  <h><a rel='prev' href='http://w3future.com/weblog/2004/05/07.xml#a245' title='Friday, May 07, 2004'>&lt;&#160;</a><a href="http://w3future.com/weblog/2004/05/13.xml">Thursday, May 13, 2004</a><a rel='next' href='http://w3future.com/weblog/2004/06/01.txt#a247' title='Tuesday, June 01, 2004'>&#160;&gt;</a></h>
<a name="a275"></a>
<section id="a275">
<h id='moiellTeaser'><a href="http://w3future.com/weblog/2004/05/13.xml#a275" class="weblogItemTitle">Moiell teaser</a></h>
<p>Almost a year ago I wrote about <a href="http://w3future.com/weblog/2003/05/21.xml#xpath20Sequences">adding sequences to Loell</a>. I did a few attempts but failed. Then a month ago I implemented continuations in Javascript. (It's not pretty.) After that it went pretty smooth. All languages may by Turing complete, but some language features can make the difference between being able to solve a problem or not. Even if that feature is simply implemented in the language itself.</p>
<p>The result turned out to be rather different from the original Loell, so I gave it a new name: <em>Moiell</em>. It stands for Monadic Objects, Iterative Evaluation, Little Language. I'll explain later.</p><p>The reason I'm now posting about this is that I got the following code running:</p>
<pre>sieve: [|p::ns| &gt;p, sieve( ns[me mod p != 0] ) ]
>sieve(2..inf)</pre>
<p>It generates the prime numbers using <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">the sieve of Eratosthenes</a>. I think it's really cool short code. A little bit of explanation:</p>
<ul>
<li><code>[|args| body]</code> &#8212; a function (as in Smalltalk)</li>
<li><code>x::xs</code> &#8212; put first value of a sequence in <code>x</code> and the rest (lazily) in <code>xs</code> (like <code>x:xs</code> in Haskell)</li>
<li><code>&gt; values</code> &#8212; yield values (like <code>yield</code> in Python or Ruby)</li>
<li><code>values[test]</code> &#8212; filter (as in XPath)</li>
</ul>
</section>
</section>
<xi:include href='http://w3future.com/tools/rdf.php?about=http://w3future.com/weblog/2004/05/13.xml' /></section>
<section id="navigation"><xi:include href="http://w3future.com/w3f/sections.xml" /></section>
<section id="sidebar"><xi:include href="http://w3future.com/weblog/sidebars/weblog.opml" /></section>
</body>
</html>

