Palidrome checker in haskell I decided to avoid the trivial isPalindrome lst = lst == reverse lst and tried writing a method with pattern matching and recursion.

allButFirstAndLast :: [a] -&gt; [a]
allButFirstAndLast = tail . init

isPalidrome :: [a] -&gt; Bool
isPalidrome [] = True
isPalindrome [a] = True
isPalindrome [a,b] = a == b
isPalindrome lst = (isPalindrome (allButFirstAndLast lst)) &amp;&amp;
                   ((head lst) == (last lst))
The implementation is correct, but not efficient. The problem are the calls to last and init, which are both O(n), which makes the whole function O(n^2). On the other hand, lst == reverse lst is just O(n).

See Finding palindromes in a linked list.

Also the pattern

isPalindrome [a,b] = a == b


is redundant, you can omit it and let it be handled by the generic case.