For starters...

Isaac Dupree isaacdupree at charter.net
Thu Jul 17 11:09:42 EDT 2008


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


More information about the Beginners mailing list