Q:

Checking if two lists are equal at Nth position

I've just started learning Haskell as a module in my CS degree. 
Currently trying to create a function which takes a list [Int] and a list [Integer]. 
My goal is to check if the two lists are equal at the n-th position.
So far, i've been able to compare two [Int] lists to see if they're equal. 
compareList :: [Int] -> [Int] -> Bool 
compareList x y = x == y 

But i am unsure how to compare at the n-th position. If someone could help me that would be great. 
Thanks in advance, 
sam 

A:

(Assuming that element indexing starts at 0.)
The n:th element of a list is the same as the (n-1):th element of its tail, so we can use recursion over the lists.
It's easy to compare the first (0:th) position of two non-empty lists:
compareLists (x:xs) (y:ys) 0 = x == y

It's also easy if one or both of the lists is empty, if we adopt the convention that the n:th elements are unequal if they don't exist:
compareLists [] [] n = False
compareLists [] (y:ys) n = False
compareLists (x:xs) [] n = False

(These cases can be combined somewhat, but I'm spelling them out in the hope that it's clearer.)
And for the general case, take the tails of the two lists and compare their (n-1):th elements:
compareLists (x:xs) (y:ys) n = compareLists xs ys (n - 1)

