1

So I am trying to implement a maximum function but for some reason I am getting a parse error on the last line "mymax x:y:ys = ..... " . What is the reason for that error? Thanks!

mymax :: Ord a=>[a]->Maybe a
mymax [] = Nothing
mymax [x] = Just x
mymax x:y:xs = if (x < y) 
            then mymax(y:xs) 
            else mymax(x:xs)
1

2 Answers 2

3

You're missing the parentheses:

mymax (x:y:xs) = if (x < y) 
                 ...
Sign up to request clarification or add additional context in comments.

Comments

2

Put parenthesis around x:y:xs

mymax (x:y:xs) = ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.