sashan
2003-05-05 02:30:18 UTC
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.
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.