maxList
Nuno Silva
nunopedrosilva@yahoo.com
Fri, 13 Sep 2002 07:42:45 -0700 (PDT)
--0-1537142547-1031928165=:31160
Content-Type: text/plain; charset=us-ascii
hello, I'm new to haskell, I'm studying for an exam, and I'm having trouble with this exercise.
I have a list of Integers, and I want to return the highest value of all.
i have this:
comp :: Int -> Int -> Int
comp x y | x < y = y
| otherwise = x
maxList :: [Int] -> [Int]
maxList (x1:x2:xs) = comp x1 x2 : maxList xs
maxList [] = []
this code returns a list, but I only want it to return a single Int... but can't seem to do it, could you please help me?
---------------------------------
Do you Yahoo!?
Yahoo! News - Today's headlines
--0-1537142547-1031928165=:31160
Content-Type: text/html; charset=us-ascii
<P>hello, I'm new to haskell, I'm studying for an exam, and I'm having trouble with this exercise.</P>
<P>I have a list of Integers, and I want to return the highest value of all.</P>
<P>i have this: </P>
<P>comp :: Int -> Int -> Int</P>
<P>comp x y | x < y = y</P>
<P> | otherwise = x</P>
<P>maxList :: [Int] -> [Int]</P>
<P>maxList (x1:x2:xs) = comp x1 x2 : maxList xs</P>
<P>maxList [] = []</P>
<P> </P>
<P>this code returns a list, but I only want it to return a single Int... but can't seem to do it, could you please help me?</P><p><br><hr size=1>Do you Yahoo!?<br>
<b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's headlines
--0-1537142547-1031928165=:31160--