]> git.rkrishnan.org Git - sicp.git/commitdiff
solution to 2.54
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Tue, 23 Nov 2010 18:21:23 +0000 (23:51 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Tue, 23 Nov 2010 18:21:23 +0000 (23:51 +0530)
src/sicp/ex2_54.rkt [new file with mode: 0644]

diff --git a/src/sicp/ex2_54.rkt b/src/sicp/ex2_54.rkt
new file mode 100644 (file)
index 0000000..ef27b5a
--- /dev/null
@@ -0,0 +1,13 @@
+#lang racket
+
+(define (equal? s1 s2)
+  (cond ((null? s1) (null? s2))
+        ((and (symbol? s1) 
+              (symbol? s2)) (eq? s1 s2))
+        ((and (number? s1) 
+              (number? s2)) (= s1 s2))
+        ((and (pair? s1)
+              (pair? s2)
+              (equal? (car s1) 
+                      (car s2))) (equal? (cdr s1) (cdr s2)))
+        (else #f)))