| Paste number 80683: | Simple binary tree constructor |
| Pasted by: | gnuvince |
| When: | 8 months, 2 weeks ago |
| Share: | Tweet this! | http://paste.lisp.org/+1Q97 |
| Channel: | #clojure |
| Paste contents: |
(def *count* (atom 0))
(defstruct node :children)
(defn make-node [children]
(swap! *count* inc)
(struct node children))
(defn make-tree [depth]
(if (> depth 1)
(make-node [(make-tree (dec depth)) (make-tree (dec depth))])
(make-node [])))
(let [depth (if *command-line-args*
(Integer/parseInt (first *command-line-args*))
10)]
(make-tree depth)
(println @*count*))
This paste has no annotations.