I will use foldr max 0, because I want 0 for the empty list.



On Thu, Jul 17, 2008 at 12:09, Isaac Dupree <isaacdupree@charter.net> wrote:
Marco Túlio Gontijo e Silva wrote:
Hi.

Em Qui, 2008-07-17 às 11:42 -0300, Felipe Lessa escreveu:
f = sum &&& foldr max 0 >>> uncurry (-)

You can replace
foldr max 0
with simply
foldr1 max
or even
maximum

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.

-Isaac

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners



--
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.