[Haskell-beginners] Get max element of a list using foldl or foldr

jamb at hinojosa.com jamb at hinojosa.com
Fri Sep 25 23:18:08 UTC 2015


Hello,

I am a complete Haskell beginner and I am doing some exercises of my 
book but I am stuck with the following:

Define
myMax :: Ord a => [a] -> a
which returns the maximum element of a list.

I must use foldl1 or foldr1 and I am given the hint to use max which 
gets the maximum of 2 elements.

I will very much appreciate if you help me solve it.

Thanks in advance,
JAMB



More information about the Beginners mailing list