Skip to content

Instantly share code, notes, and snippets.

@yitznewton
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save yitznewton/0fecf8938804fc4bab80 to your computer and use it in GitHub Desktop.

Select an option

Save yitznewton/0fecf8938804fc4bab80 to your computer and use it in GitHub Desktop.
Pascal's Triangle
(define (pascal row col)
(define (row_underflow? col) (< col 0))
(define (row_overflow? row col) (> col row))
(define (initial_cell? row) (= row 0))
(cond
((row_underflow? col) 0)
((row_overflow? row col) 0)
((initial_cell? row) 1)
(else
(+
(pascal (- row 1) (- col 1))
(pascal (- row 1) col)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment