From 0e9889fcc24d5818ef4f3545a824f385f147d322 Mon Sep 17 00:00:00 2001 From: jim Date: Sat, 14 Feb 2015 07:55:34 -0500 Subject: [PATCH] create page --- exercises/assignment3_hint3.mdwn | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 exercises/assignment3_hint3.mdwn 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? -- 2.11.0