(no commit message)
[lambda.git] / hints / assignment_4_hint_2.mdwn
index 5ee63f5..f9f4cf2 100644 (file)
@@ -15,39 +15,6 @@ What's your base case?
 
 
 <!--
-eql [] l2        = empty l2
-eql (l1h:l1t) l2 = and (not (empty l2))
-                       (l1h == head l2)
-                       (eql l1t (tail l2))
-
-Simple rearangement:
-
-eql []        = \l2 -> empty l2
-eql (l1h:l1t) = \l2 -> and (not (empty l2))
-                       (l1h == head l2)
-                       (eql l1t (tail l2))
-
-and another one rearrangement:
-
-eql []        = \l2 -> empty l2
-eql (l1h:l1t) = let prev = eql l1t
-                in \l2 -> and (not (empty l2))
-                              (l1h == head l2)
-                              (prev (tail l2))
-
-Now it fits the pattern of foldr
-
-So, the end result:
-
-eql = foldr f z
- where
- z = empty
- f h z = \l2 -> and (not (empty l2))
-                    (h == head l2)
-                    (z (tail l2))
--->
-
-<!--
 let list_equal =
     \left right. left
                 ; here's our f
@@ -71,3 +38,23 @@ let list_equal =
                 (\might_be_equal right_tail. and might_be_equal (isempty right_tail))
 -->
 
+<!--
+list_equal [] right      = isempty right
+list_equal (hd:tl) right = and (not (isempty right))
+                            (hd == head right)
+                            (list_equal tl (tail right))
+
+Rearangement:
+
+list_equal []      = \right -> isempty right
+list_equal (hd:tl) = let prev = list_equal tl
+                     in \right -> and (not (isempty right))
+                                   (hd == head right)
+                                   (prev (tail right))
+
+Now it fits the pattern of fold_right
+
+let list_equal = \left. left (\hd sofar. \right. and (and (not (isempty right)) (eq hd (head right))) (sofar (tail right))) isempty
+
+-->
+