Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recursivley compute the elements of Pascal's triangle in Scheme. Answer to SICP exercise 1.12
;; Recursive function to compute the elements
;; of Pascal's triangle. Note the complete lack
;; of any sanity checks on the input. GIGO.
(define (pelem row col)
(cond((= col 0) 1)
((= col row) 1)
(else(+(pelem(- row 1)(- col 1))
(pelem(- row 1) col) ) )))
@enigmaticape

This comment has been minimized.

Copy link
Owner Author

enigmaticape commented Nov 16, 2012

Recursivley compute the elements of Pascal's triangle in Scheme. Solution to SICP exercise 1.12, discussed at http://www.enigmaticape.com/blog/sicp-exercise-1-12-pascals-triangle-recursively/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.