Lists and List Comprehensions
- Suppose you have two lists of integers,
right. You want to determine whether those lists are equal, that is, whether they have all the same members in the same order. How would you implement such a list comparison?
Here are some hints.
, what does
righthave to be for
rightto be equal? (Come on, it's not too hard.)
Suppose on the other hand that
, and its head isn't equal to
, and its head is equal to
x, what else has to be the case for
rightto be equal?
Can you now write a recursive definition of the
list_equalfunction? What's your base case?