Question: In Haskell, Why is the code below an error? -------------------- maximum' :: (Ord a) => [a] -> a maximum' [] = error maximum of empty
In Haskell,
Why is the code below an error?
--------------------
maximum' :: (Ord a) => [a] -> a
maximum' [] = error "maximum of empty list"
maximum' [x] = x
maximum' (x:xs)
| x > maxTail = x
| otherwise = maxTail
where maxTail = maximum' xs

17 18 19 20 21 maximum' :: (Ord a) => [a] -> a maximum' [] = error "maximum of empty list" maximum' [x] = x maximum' (x:xs) | x > maxTail = x | otherwise = maxTail where maxTail = maximum' xs 22 23 24 PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL *Practice> maximum' [5,4,1,2,4]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
