alternate Y1,Y2 tweak
[lambda.git] / hints / assignment_4_hint_3_alternate_1.mdwn
1 Alternate strategy for Y1, Y2
2
3 *       This is (in effect) the strategy used by OCaml. The mutually recursive:
4
5         let rec
6                 f x = A  ; A may refer to f or g
7         and
8                 g y = B  ; B may refer to f or g
9         in
10                 C
11
12 is implemented using regular, non-mutual recursion, like this (`u` is a variable not occurring free in `A`, `B`, or `C`):
13
14         let rec u g x = (let f = u g in A)
15         in let rec g y = (let f = u g in B)
16         in let f = u g in C
17
18 or, expanded into the form we've been working with:
19
20         let u = Y (\u g x. (\f. A) (u g)) in
21         let g = Y (\g y. (\f. B) (u g)) in
22         let f = u g
23