I was asked to make a function that works like foldr
but with non empty lists, that works like this: foldr1 f [x1,x2...xn] = f x1 (f x2...(f xn-1 xn)...)
.
So I defined it like this:
foldr1 f [x] = x
foldr1 f (x:xs) = f x (foldr1 f xs)
foldr1 f _ = undefined
And I'm still getting "Non-exhaustive patterns in function foldr1" error, despite covering all possibilities. What am I doing wrong?