From e14a493f3df7e2e501265518ffa3a6b70a88ca1c Mon Sep 17 00:00:00 2001 From: jim Date: Fri, 20 Feb 2015 12:58:31 -0500 Subject: [PATCH] add chris's YY question, further refinements elsewhere --- exercises/_assignment4.mdwn | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/exercises/_assignment4.mdwn b/exercises/_assignment4.mdwn index 3eec4e6a..7c01388b 100644 --- a/exercises/_assignment4.mdwn +++ b/exercises/_assignment4.mdwn @@ -16,10 +16,14 @@ find terms `F`, `G`, and `Î¾` such that `F Î¾ <~~> Î¾` and `G Î¾ <~~> Î¾`. (If you need a hint, reread the notes on fixed points.) +4. Assume that `Î¨` is some fixed point combinator; we're not telling you which one. (You can just write `Psi` in your homework if you don't know how to generate the symbol `Î¨`.) Prove that `Î¨ Î¨` is a fixed point of itself, that is, that `Î¨ Î¨ <~~> Î¨ Î¨ (Î¨ Î¨)`. + + Y(YY) --> YY(Y(YY)); YY(YY) --> YY(Y(YY)) --> + ## Writing recursive functions ## -4. Helping yourself to the functions given below, +5. Helping yourself to the functions given below, write a recursive function called `fact` that computes the factorial. The factorial `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. For instance, `fact 0 ~~> 1`, `fact 1 ~~> 1`, `fact 2 ~~> 2`, `fact 3 ~~> @@ -42,7 +46,7 @@ For instance, `fact 0 ~~> 1`, `fact 1 ~~> 1`, `fact 2 ~~> 2`, `fact 3 ~~> fac 4 -5. 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_more_lists_]]. +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_more_lists_]].