Last active
June 6, 2018 23:36
-
-
Save sundarj/755ada7d29bd02aa063c25821b4c4d1f 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
(defn depth [coll] | |
(count (->> coll | |
(tree-seq coll? identity) | |
(filter coll?)))) | |
(defn comp-times [n f] | |
(reduce comp | |
f | |
(repeat (dec n) f))) | |
(let [coll [[[1 2 3]]] | |
the-depth (dec (depth coll)) | |
xform (comp (comp-times the-depth cat) | |
(map inc)) | |
uncat (comp-times the-depth vector) | |
rf (completing conj uncat)] | |
(transduce xform rf coll)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment