# lambda chops

The SICP adventures of lilburns and yowak

• Amazing low-poly isometric worlds by Timothy J. Reynolds.

— yw

• “The symbolic forms which Mr. Betts has evolved through his system of Representation resemble, when developed in two dimensions, conventionalised but very scientifically and beautifully conventionalised leaf-outlines. When in more than two dimensions they approximate to the forms of flowers and crystals. …. The fact that he has accidentally portrayed plant-forms when he was studying human evolution is an assurance to Mr. Betts of the fitness of the symbols he has developed, as it affords presumptive evidence that the laws he is studying intuitively admit of universal application.”

(via tytodiem)

Source: publicdomainreview.org

• ### SICP Exercise 1.16

"Design a procedure that evolves an interative exponentiation process that uses successive squaring and uses a logarithmic number of steps …"

So, we want to calculate $$b^n$$ using an iterative (rather than recursive) process which uses successive squaring1 to calculate $$b^n$$ in a logarithmic number of steps.2

My solution3 (excuse the tacky syntax highlighting):

(define (fast-expt b n)
(define (even? x)
(= (remainder x 2) 0))
(define (fast-expt-iter b counter a)
(display (* a b))
(display " ")
(cond ((= counter 0) a)
((even? counter) (fast-expt-iter (square b) (/ counter 2) a))
(else (fast-expt-iter b (- counter 1) (* a b)))))
(fast-expt-iter b n 1))


— yowak

1. i.e. Taking advantage of the fact that $$b^n = (b^{n/2})^2$$.

2. In this particular case, the number of steps in the process increases proportional to $$\log_2(n)$$; a doubling of $$n$$ requires only 1 extra step.

3. To save space, I haven’t bothered to include a definition of square

• Generative Art by Tom Beddard.

• ### lambda chops on github

We’ll be posting our code and notes to github as we go. Check it out.

• ### Preamble

lambda chops: SICP log of lilburns & yowak. Exercises, notes, inspirations, ephemera.

SICP: Structure & Interpretation of Computer Programs, by Abelman & Sussman

lilburns: Simon Lilburn

yowak: Yoshua Wakeham