Created
March 27, 2010 01:37
-
-
Save ecounysis/345616 to your computer and use it in GitHub Desktop.
This file contains 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 | |
(lambda (x) | |
(letrec ([last | |
(lambda (x) | |
(if (null? (cdr x)) x (last (cdr x))))] | |
[sum-two | |
(lambda (x) | |
(+ (car x) (cadr x)))] | |
[sum-doubles | |
(lambda (x) | |
(cond ((null? (cdr x)) (last x)) | |
(else (cons (sum-two x) (sum-doubles (cdr x))))))] | |
[pascal-sub | |
(lambda (x) | |
(cons (car x) (sum-doubles x)))]) | |
(cond ((= x 1) (list 1)) | |
(else (pascal-sub (pascal (- x 1)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment