From 1859a8c4b42139e3a557ec44dd8edd1e1acb71f9 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sun, 3 Oct 2010 21:26:51 -0400 Subject: [PATCH] assign 4: hints for list_equal Signed-off-by: Jim Pryor --- hints/assignment_4_hint_2.mdwn | 50 +++++++++++++++++++++++++++++++++++++++++- lambda_library.mdwn | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) 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 -- 2.11.0