Created
April 17, 2012 22:26
-
-
Save tron1point0/2409467 to your computer and use it in GitHub Desktop.
I'm an ass.
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
pascal' :: [Int] -> [Int] | |
pascal' l | |
| length l < 2 = [1] | |
| otherwise = (a + b) : (pascal' (b:rest)) | |
where a:(b:rest) = l | |
pascal :: [Int] -> [Int] | |
pascal = (1:) . pascal' |
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
(defun pascal% (list) | |
(if (<= (length list) 1) | |
list | |
(cons (+ (first list) (second list)) (pascal% (cdr list))))) | |
(defun pascal (prev) | |
(if (not prev) | |
'(1) | |
(cons 1 (pascal% prev)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment