some solutions for MIT Press's "structure and interpretation of computer programs", I guess
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 45 lines 1.1 KiB Raw Permalink Blame History

 `(define (A x y)` ` (cond ((= y 0) 0)` ` ((= x 0) (* 2 y))` ` ((= y 1) 2)` ` (else (A (- x 1) (A x (- y 1))))))` `(A 1 10)` `;; -> (A 0 (A 1 9))` `;; -> (A 0 (A 0 (A 1 8))` `;; -> (A 0 (A 0 (A 0 (A 1 7))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 1 6)))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 5))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 4)))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 3))))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 2)))))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 1 1))))))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 2)))))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 4))))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 8)))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 (A 0 16))))))` `;; -> (A 0 (A 0 (A 0 (A 0 (A 0 32)))))` `;; -> (A 0 (A 0 (A 0 (A 0 64))))` `;; -> (A 0 (A 0 (A 0 128)))` `;; -> (A 0 (A 0 256))` `;; -> (A 0 512)` `;; => 1024` `(A 2 4)` `;; => 65536` `;; I'm not going to bother evaluating these by hand anymore.` `(A 3 3)` `;; => 65536` `(define (f n) (A 0 n))` `;; 2n` `(define (g n) (A 1 n))` `;; 2^n` `(define (h n) (A 2 n))` `;; 2^2^(n-1 times)` `(define (k n) (* 5 n n))` ```;; 5n^2 ``` ``` ```