Thursday, September 25, 2008

Sabbatical Update #2

I completed Chapter 2 of SICP yesterday. I am taking the day off from my regularly scheduled activities to rest and recuperate and also to write this mini-report.

While chapter 1 was definitely interesting the second chapter was far more meatier in terms of fundamental concepts presented and explored. I have written code mostly in Python and Java and had very conventional notions of 'data' in the programming context. The authors of SICP challenge that notion almost right from the beginning of the chapter. They present - and illustrate - the idea that data can be thought of as "some collection of selectors and constructors, together with specified conditions that these procedures must fulfill in order to be a valid representation". The rest of the chapter builds on this fundamental concept working on more complex data including a mini "picture language".

It took me some time to digest this idea and longer to deal with some of the exercises. One particular exercise involved implementing Church Numerals using Scheme. Church Numerals are the brain child of mathematician Alonzo Church who first described a way to embed data and operators into lambda calculus. I thought the name 'Church Numerals' was a misnomer seeing that these were not 'numerals' in any way I have come to understand :-P Jokes aside the exercise was thought provoking. In case you were wondering this is what "0" and "1" look like:
    ;; zero
    (define zero (lambda (f) (lambda (x) x)))

    ;; one
    (define one (lambda (f) (lambda (x) (f x))))

I later realized that my troubles arose from my focus on the form of numbers rather than the function they served. Once I understood the distinction between the two it became easier to address the problem.

On a related note I will be putting up my solutions to the SICP problems shortly, starting with Chapter 2.