From d4d2725db9c0d3367d8418971bdddf4ceaba73e1 Mon Sep 17 00:00:00 2001 From: jim Date: Fri, 20 Feb 2015 13:06:19 -0500 Subject: [PATCH 1/1] need empty? for set questions --- exercises/_assignment4.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/_assignment4.mdwn b/exercises/_assignment4.mdwn index 1ef8917b..441d773f 100644 --- a/exercises/_assignment4.mdwn +++ b/exercises/_assignment4.mdwn @@ -48,7 +48,6 @@ For instance, `fact 0 ~~> 1`, `fact 1 ~~> 1`, `fact 2 ~~> 2`, `fact 3 ~~> 6. For this question, we want to implement **sets** of numbers in terms of lists of numbers, where we make sure as we construct those lists that they never contain a single number more than once. (It would be even more efficient if we made sure that the lists were always sorted, but we won't try to implement that refinement here.) To enforce the idea of modularity, let's suppose you don't know the details of how the lists are implemented. You just are given the functions defined below for them (but pretend you don't see the actual definitions). These define lists in terms of [[one of the new encodings discussed last week|/topics/week3_lists#v5-lists]]. @@ -66,6 +65,7 @@ For instance, `fact 0 ~~> 1`, `fact 1 ~~> 1`, `fact 2 ~~> 2`, `fact 3 ~~> let neg = \b y n. b n y in let empty = \f n. n in let cons = \x xs. \f n. f x xs in + let empty? = \xs. xs (\y ys. false) true in let take_while = Y (\take_while. \p xs. xs (\y ys. (p y) (cons y (take_while p ys)) empty) empty) in let drop_while = Y (\drop_while. \p xs. xs (\y ys. (p y) (drop_while p ys) xs) empty) in ... -- 2.11.0