lambda chops
The SICP adventures of lilburns and yowak

20121020

20121015
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 squaring^{1} to calculate \(b^n\) in a logarithmic number of steps.^{2}
My solution^{3} (excuse the tacky syntax highlighting):
(define (fastexpt b n) (define (even? x) (= (remainder x 2) 0)) (define (fastexptiter b counter a) (display (* a b)) (display " ") (cond ((= counter 0) a) ((even? counter) (fastexptiter (square b) (/ counter 2) a)) (else (fastexptiter b ( counter 1) (* a b))))) (fastexptiter b n 1))
— yowak

→

20121013
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