From: Jim Pryor Date: Mon, 4 Oct 2010 01:26:51 +0000 (-0400) Subject: assign 4: hints for list_equal X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=1859a8c4b42139e3a557ec44dd8edd1e1acb71f9 assign 4: hints for list_equal Signed-off-by: Jim Pryor --- diff --git a/hints/assignment_4_hint_2.mdwn b/hints/assignment_4_hint_2.mdwn index 78cb1bd4..5ee63f55 100644 --- a/hints/assignment_4_hint_2.mdwn +++ b/hints/assignment_4_hint_2.mdwn @@ -1,4 +1,51 @@ -Hints for list\_equal. +Hints for `list_equal`. + +* If `left` is `[]`, what does `right` have to be for `left` and `right` to be equal? (Come on, it's not too hard, you can figure it out.) + +* Suppose on the other hand that `left` has head `left_hd` and tail `left_tl`. + +
    +
  1. If `right` is then `[]`, are `left` and `right` equal? +
  2. If `right` isn't `[]`, and its head isn't equal to `left_hd`, are `left` and `right` equal? +
  3. If `right` isn't `[]` and its head *is* equal to `left_hd`, 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? + + + + diff --git a/lambda_library.mdwn b/lambda_library.mdwn index 5623b9fa..6441d3b9 100644 --- a/lambda_library.mdwn +++ b/lambda_library.mdwn @@ -314,7 +314,7 @@ let list_equal = ; (might_for_all_i_know_still_be_equal?, tail_of_reversed_right) ; when left is empty, the lists are equal if right is empty (make_pair - (not (isempty right)) + true ; for all we know so far, they might still be equal (reverse right) ) ; when fold is finished, check sofar-pair