
You'll find in the Prelude that Int is an instance of Bounded, so minBound and maxBound are defined, and are the identities you need. cheers -----Original Message----- From: sashan [mailto:sashang@ihug.co.nz] Sent: Monday, May 05, 2003 12:30 PM To: haskell-cafe@haskell.org Subject: Maximum value in a list 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. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (1)
-
Garner, Robin