Question About lists

Cesar Augusto Acosta Minoli c_minoli@hotmail.com
Mon, 30 Dec 2002 17:38:13 +0000


<html><div style='background-color:'><DIV>
<P>Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional Programming and I would like to know if there is&nbsp;a way to write a more efficient function that return the length of a list, I wrote this one:</P>
<P>long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ::&nbsp; [a]-&gt;Int<BR>long p&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp; longitud p 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; longitud []&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s=s<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; longitud (x:xs) s=longitud xs (s+1)</P>
<P>but I think that it have a lineal grow O(n).</P>
<P>thanks!</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;<BR><BR></P></DIV></div><br clear=all><hr>Add photos to your e-mail with MSN 8.  <a href="http://g.msn.com/8HMEEN/2021">Get 3 months FREE*.</a> </html>