From 7e4dba0e8b405ec49d697d11c75428584475837a Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Sun, 18 Dec 2011 12:46:06 +0530
Subject: [PATCH] solution to 4.21

---
 src/sicp/ex4_21.rkt | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 src/sicp/ex4_21.rkt

diff --git a/src/sicp/ex4_21.rkt b/src/sicp/ex4_21.rkt
new file mode 100644
index 0000000..a28f54f
--- /dev/null
+++ b/src/sicp/ex4_21.rkt
@@ -0,0 +1,38 @@
+#lang racket
+
+(define Y (lambda (f)
+            ((lambda (g) 
+               (g g))
+             (lambda (h)
+               (lambda (x)
+                 ((f (h h)) x))))))
+
+;; factorial
+((Y (lambda (fct) 
+      (lambda (n) 
+        (if (= n 1) 
+            1 
+            (* n (fct (- n 1))))))) 
+ 10)
+
+;; fibonacci
+((Y (lambda (fib) 
+      (lambda (n) 
+        (cond 
+          ((= n 0) 0) 
+          ((= n 1) 1) 
+          (else (+ (fib (- n 1))
+                   (fib (- n 2))))))))
+ 10)
+
+;; b
+(define (f x)
+  ((lambda (even? odd?)
+     (even? even? odd? x))
+   (lambda (ev? od? n)
+     (if (= n 0) true (od? ev? od? (- n 1))))
+   (lambda (ev? od? n)
+     (if (= n 0) false (ev? ev? od? (- n 1))))))
+
+(eq? (f 3) #f)
+(eq? (f 4) #t)
\ No newline at end of file
-- 
2.45.2