
5 May
2003
5 May
'03
2:30 a.m.
Hi I was reading through the tutorial Yet Another Haskell Tutorial and doing chapter 3 ex 5, write a function using foldr and max to return the maximum value in a list. I came up with the following that will work for positive numbers. maxInList :: [Int]->Int maxInList [] = 0 maxInList l = foldr max 0 l Is there an identity for the max function? Because currently if the list [-1,-3,-4] is passed to maxInList it will return 0.