<!--
-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
(\might_be_equal right_tail. and might_be_equal (isempty right_tail))
-->
+<!--
+eql [] l2 = empty l2
+eql (l1h:l1t) l2 = and (not (empty l2))
+ (l1h == head l2)
+ (eql l1t (tail l2))
+
+Rearangement:
+
+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
+
+let list_equal = \lst. lst (\hd sofar. \lst. and (and (not (isempty lst)) (eq hd (head lst))) (sofar (tail lst))) isempty
+
+-->
+
)
; when fold is finished, check sofar-pair
(\might_be_equal right_tail. and might_be_equal (isempty right_tail))
+
+; most elegant
+let list_equal = \lst. lst (\hd sofar. \lst. and (and (not (isempty lst)) (eq hd (head lst))) (sofar (tail lst))) isempty
+
-->