<div class="gmail_quote">On Fri, Feb 26, 2010 at 5:12 PM, Daniel Fischer <span dir="ltr">&lt;<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Am Freitag 26 Februar 2010 17:37:30 schrieb Magnus Therning:<br>
<div class="im">&gt; It doesn&#39;t look like a complete piece of code so these comments aren&#39;t<br>
&gt; backed up by running it through GHCi or anything.<br>
&gt;<br>
&gt; On Fri, Feb 26, 2010 at 16:29, Florian Duret &lt;<a href="mailto:flo.morphe@gmail.com">flo.morphe@gmail.com</a>&gt;<br>
wrote:<br>
&gt; &gt; Hello,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I try to set up a verification on the number of arguments given to my<br>
&gt; &gt; program, but keep on getting &quot;Parse error in pattern&quot;<br>
&gt; &gt; Here is what my code looks like:<br>
&gt; &gt; main :: IO()<br>
&gt; &gt; main = do<br>
&gt; &gt;     -- On commence par ouvrir le fichier SAC en mode binaire<br>
&gt; &gt;     argsList &lt;- getArgs<br>
&gt; &gt;     if (length (argsList) == 0)<br>
<br>
</div>It&#39;s most likely harmless for argument lists (although there are other<br>
cases), but<br>
<br>
Don&#39;t Use<br>
<br>
if (length list == 0)<br>
<br>
Never. Jamais. Niemals.<br>
<br>
Use<br>
<br>
if (null list)<br>
<br>
length has to traverse the entire list, which may take a long time.</blockquote><div><br></div><div>While the advice here is sound 90% of the time, it&#39;s evidence of falling into the trap of underestimating lazyness.  If 0 and length list are both of type Nat, the first will be exactly as fast as the second.</div>
<div><br></div><div>Bob </div></div>