Matt Bowcock // mbowcock.com

SICP Problem 1.12

without comments

Had a little time and got it done quicker than I expected. Problem 1.12 was to write a procedure to calculate elements of pascals triangle. I took that to mean calculate the value at position n of a given row. Take a look -

(define (pascal row n)   (cond ((> n row) 0)         ((or (= n 1) (= n row)) 1)         (else (+ (pascal (- row 1) n) (pascal (- row 1) (- n 1))))))

Written by matt

October 9th, 2009 at 3:20 pm

Posted in notebook

Tagged with

Leave a Reply