<?xml version="1.0" encoding="windows-1252"?>
<node id="590182" title="Re^10: 99 Problems in Perl6" created="2006-12-16 04:01:30" updated="2006-12-15 23:01:30">
<type id="11">
note</type>
<author id="368438">
gaal</author>
<data>
<field name="doctext">
Ordered variants in Haskell let you do things like

&lt;p&gt;&lt;c&gt;
funky (x:y:xs) = ... -- I'm guaranteed to have two elements or more
funky (x:xs)   = ... {- This pattern would have matched a long list, but since
                        the previous variant came first, we know the list is
                        of length 1 or 2. *
                     -}
&lt;/c&gt;&lt;/p&gt;

This is incredibly useful sometimes. Okay, when I want &lt;c&gt;when&lt;/c&gt; I know where to find it. :-)

&lt;p&gt;* For folks not familiar with Haskell who count three or two items in the two patterns and don't see why I'm talking of lists of at least two and one or two elements respectively: in Haskell, "&lt;c&gt;(a:b)&lt;/c&gt;" means a is an element and b is a list of zero or more elements. That's why by convention you see names like "xs" and "ys", pronounced "exes" and "whys", though there's nothing in the language to enforce names like that. The expression &lt;c&gt;(x:y:xs)&lt;/c&gt; means &lt;c&gt;(x:(y:xs))&lt;/c&gt;.</field>
<field name="root_node">
590113</field>
<field name="parent_node">
590157</field>
</data>
</node>
