Skip to content

Instantly share code, notes, and snippets.

@jonase
Created October 27, 2010 15:53
Show Gist options
  • Save jonase/649317 to your computer and use it in GitHub Desktop.
Save jonase/649317 to your computer and use it in GitHub Desktop.
;; 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