Skip to content

Instantly share code, notes, and snippets.

@tron1point0
Created April 17, 2012 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tron1point0/2409467 to your computer and use it in GitHub Desktop.
Save tron1point0/2409467 to your computer and use it in GitHub Desktop.
I'm an ass.
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'
(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