summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-07-02 00:58:08 +0000
committerrsiddharth <s@ricketyspace.net>2016-07-02 00:58:08 +0000
commitbd26d42331f13a469e8a9525a7289207c8da17e0 (patch)
tree5945a47ccf8774c0405318e7f5d0111d96629973
parente63ca8e496f7a4e34d88f8ef94574783cb62fa03 (diff)
did some ex 1.10.
-rw-r--r--sicp.org62
1 files changed, 62 insertions, 0 deletions
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)