Skip to content

Instantly share code, notes, and snippets.

@shinmuro
Last active August 29, 2015 13:56
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 shinmuro/9133673 to your computer and use it in GitHub Desktop.
Save shinmuro/9133673 to your computer and use it in GitHub Desktop.
4Clojure#95 altenative answer
;; This answer cannot use in 4Clojure
(use 'clojure.zip)
(fn binary-tree? [root]
(let [zp (zipper coll? rest (fn [n c] c) root)]
(->> (take-while (complement end?) (iterate next zp))
(filter branch?)
(every? #(= (count (children %)) 2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment