I want to check if two lists A and B are equal, i.e., a1 == b1, a2 == b2,…
I have a working solution:
all (\x->x) zipWith $ (==) A B
Another idea is to do it recursively: a:as, b:bs ; check if a1==b1 and call the function with the remaining lists as and bs. But isn’t there an easier and more readable way to do this?
You can just use
==on them directly.This is because
==is part of theEqtype class, and there is anEqinstance for lists which looks something like this:This means that lists instantiate
Eqas long as the element type also instantiatesEq, which is the case for all types defined in the standard Prelude except functions andIOactions.