Skip to content

Instantly share code, notes, and snippets.

@jonase jonase/pascal.clj
Created Oct 27, 2010

Embed
What would you like to do?
;; Simple example for generating Pascal's triangle
;; using chouser's finger-tree
(use 'clojure.data.finger-tree
'clojure.pprint)
(def pascal
(iterate #(into (double-list)
(map +
(conjr % 0)
(consl % 0)))
(double-list 1)))
(pprint (take 7 pascal))
;; user=> (load-file "pascal.clj")
;; ((1)
;; (1 1)
;; (1 2 1)
;; (1 3 3 1)
;; (1 4 6 4 1)
;; (1 5 10 10 5 1)
;; (1 6 15 20 15 6 1))
;; nil
;; user=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.