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

In Haskell, Why is the code below an error? -------------------- maximum' ::

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] :15:1: error: ? Variable not in scope: maximum' :: [ae] -> t ? Perhaps you meant 'maximum' (imported from Prelude) *Practice> maximum' [5,4,1] interactive>:16:1: error: ? Variable not in scope: maximum' :: [ab] -> t ? Perhaps you meant 'maximum' (imported from Prelude) *Practice | 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] :15:1: error: ? Variable not in scope: maximum' :: [ae] -> t ? Perhaps you meant 'maximum' (imported from Prelude) *Practice> maximum' [5,4,1] interactive>:16:1: error: ? Variable not in scope: maximum' :: [ab] -> t ? Perhaps you meant 'maximum' (imported from Prelude) *Practice |

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!