]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_54.rkt
solutions to 4.35, 4.36 and 4.37
[sicp.git] / src / sicp / ex2_54.rkt
1 #lang racket
2
3 (define (equal? s1 s2)
4   (cond ((null? s1) (null? s2))
5         ((and (symbol? s1) 
6               (symbol? s2)) (eq? s1 s2))
7         ((and (number? s1) 
8               (number? s2)) (= s1 s2))
9         ((and (pair? s1)
10               (pair? s2)
11               (equal? (car s1) 
12                       (car s2))) (equal? (cdr s1) (cdr s2)))
13         (else #f)))