<div dir="ltr">I will use foldr max 0, because I want 0 for the empty list.<br><br><br><br><div class="gmail_quote">On Thu, Jul 17, 2008 at 12:09, Isaac Dupree <<a href="mailto:isaacdupree@charter.net">isaacdupree@charter.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Marco Túlio Gontijo e Silva wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi.<br>
<br>
Em Qui, 2008-07-17 às 11:42 -0300, Felipe Lessa escreveu:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
f = sum &&& foldr max 0 >>> uncurry (-)<br>
</blockquote>
<br>
You can replace<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
foldr max 0<br>
</blockquote>
with simply<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
foldr1 max<br>
</blockquote>
or even<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
maximum<br>
</blockquote></blockquote>
<br></div>
If it's important that the function return 0 when given an empty list, then you don't want to use foldr1 or maximum. But, if you don't need it to, then it may be sounder to have it fail on an empty list, because it's not particularly well-defined what it should return then.<br>
<font color="#888888">
<br>
-Isaac</font><div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Rafael Gustavo da Cunha Pereira Pinto<br>Electronic Engineer, MSc.
</div>