Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created October 30, 2012 05:13
Show Gist options
  • Save aoeuidht/3978427 to your computer and use it in GitHub Desktop.
Save aoeuidht/3978427 to your computer and use it in GitHub Desktop.
SICP Exercise 1.12 -- Pascal's triangle
;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