Created
October 30, 2012 05:13
-
-
Save aoeuidht/3978427 to your computer and use it in GitHub Desktop.
SICP Exercise 1.12 -- 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
;The following pattern of numbers is called Pascal's triangle | |
(defun pascal_x_y (x y) | |
(if (or (= y 0) (= x y)) | |
1 | |
(+ (pascal_x_y (- x 1) (- y 1)) | |
(pascal_x_y (- x 1) y)))) | |
(defun draw_line (n) | |
(loop for idx from 0 to n do | |
(prin1 (pascal_x_y n idx)) | |
(format t " ")) | |
(format t "~%")) | |
(defun draw_pascal (n) | |
(loop for line from 0 to n do | |
(draw_line line))) | |
(draw_pascal 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment