Last active
August 29, 2015 14:14
-
-
Save yitznewton/0fecf8938804fc4bab80 to your computer and use it in GitHub Desktop.
Pascal's Triangle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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