From bd26d42331f13a469e8a9525a7289207c8da17e0 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 2 Jul 2016 00:58:08 +0000 Subject: did some ex 1.10. --- sicp.org | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/sicp.org b/sicp.org index db960ea..38e7106 100644 --- a/sicp.org +++ b/sicp.org @@ -147,3 +147,65 @@ other functions. (+ 0 9) | 9 <------+ #+END_SRC +*** 10 +#+BEGIN_SRC scheme +(define (A x y) + (cond ((= y 0) 0) + ((= x 0) (* 2 y)) + ((= y 1) 2) + (else (A (- x 1) + (A x (- y 1)))))) +#+END_SRC + +**** (A 1 10) = 2^y + +#+BEGIN_SRC scheme +(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 +#+END_SRC + +At this point, I'm guessing function ~A = 2^xy~. + +After some thinking, I don't think it is ~A = 2^xy~. I'm guessing it +is ~A = 2x2^y~. + +**** (A 2 4) +#+BEGIN_SRC scheme +(A 2 4) +(A 1 (A 2 3)) +(A 1 (A 1 (A 2 2))) +(A 1 (A 1 (A 1 (A 2 1)))) +(A 1 (A 1 (A 1 2))) +(A 1 (A 1 (A 0 (A 1 1)))) +(A 1 (A 1 (A 0 2))) +(A 1 (A 1 4)) +(A 1 (A 0 (A 1 3))) +(A 1 (A 0 (A 0 (A 1 2)))) +(A 1 (A 0 (A 0 (A 0 (A 1 1))))) +(A 1 (A 0 (A 0 (A 0 2)))) +(A 1 (A 0 (A 0 4))) +(A 1 (A 0 8)) +(A 1 16) +2^16 = (expt 2 16) = 65536 +#+END_SRC + + +**** (A 3 3) -- cgit v1.2.3