I’m doing SICP   Leave a comment

For Christmas, my lovely Father, and my sister Aiesha (and her boyfriend) gave me a present. That present was the book, Structure and Interpretation of Computer Programs (SICP). I really like this book, because, after about two years of trying to gain programming knowledge from reading tutorials, I am finally learning some concrete ideas. So far, I’ve managed to go through Chapter 1, with just a few hiccups. I didn’t really understand all of the math behind the calculus related stuff, and so, for example, I didn’t manage to implement differentiation through the use of Simpson’s Rule. However, I ended up getting nicely to the end of Chapter 1, and I feel fairly confident about the concepts that I’ve learned.

I like math, especially geometry, because the euphoria you experience when you solve a particularly difficult problem (relative to your skill, of course) is simply awesome. I get the same euphoria when I hack a particularly nice solution. I was very happy when I finally figured out the iterative fast exponentiation procedure, and here it is :)

;;Exercise 1.16
;;Need to define even? and square
(define (even? x) (= (remainder x 2) 0))
(define (square x) (* x x))

(define (fast-expt b n a)
(cond ((= n 0) a)
((even? n) (fast-expt (square b) (/ n 2) a))
(else (fast-expt b (- n 1) (* a b)))))

One of the great things about this book, or at least about the problems in the first chapter, is that I was able to solve most of them by hand, using just pen and paper, and my graphical calculator. It’s nice to just lie in bed, mulling over a problem, and writing out epiphanies as they come (that’s what happened in the example above). Anyway, I’m quite happy with Chapter 1, and so, onto Chapter 2!


Posted 22/03/2010 by Emmanuel Jacyna in SICP

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: