From: jim Date: Sat, 14 Feb 2015 12:55:34 +0000 (-0500) Subject: create page X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=0e9889fcc24d5818ef4f3545a824f385f147d322 create page --- diff --git a/exercises/assignment3_hint3.mdwn b/exercises/assignment3_hint3.mdwn new file mode 100644 index 00000000..a58e0bdd --- /dev/null +++ b/exercises/assignment3_hint3.mdwn @@ -0,0 +1,15 @@ +## Lists and List Comprehensions + +8. Suppose you have two lists of integers, `left` and `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.* + +* If `left` is `[]`, what does `right` have to be for `left` and `right` to be equal? (Come on, it's not too hard.) + +* Suppose on the other hand that `left` has head `x` and tail `xs`. + + 1. If `right` is then `[]`, are `left` and `right` equal? + 2. If `right` isn't `[]`, and its head isn't equal to `x`, are `left` and `right` equal? + 3. If `right` isn't `[]`, and its head *is* equal to `x`, what else has to be the case for `left` and `right` to be equal? + +* Can you now write a recursive definition of the `list_equal` function? What's your base case?