Skip to main content.
-->
March 22nd, 2005

Solution to SICP Exercise 1.12

Structure and Interpretation of Computer Programs

Solution to Exercise 1.12:

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

Posted by Ken Dyck in Programming

1 Comment »

This entry was posted on Tuesday, March 22nd, 2005 at 8:23 pm and is filed under Programming. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Solution to SICP Exercise 1.12”

  1. Rob G says:

    I have the same procedure but I just added some protective conditions to deal wonky input such as:
    (note: I consider rows and cols to both begin with index 0)
    col gt row, row lt 0, col lt 0

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>