Created
October 27, 2010 15:53
-
-
Save jonase/649317 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
;; 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