Guest User

Untitled

a guest
Jan 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. (defn tree-seq [branch? children root]
  2. (eduction (take-while some?) (map #(aget % 0))
  3. (iterate (fn [[node pair]]
  4. (when-some [[[node' & r] cont] (if (branch? node)
  5. (if-some [cs (not-empty (children node))]
  6. #js [cs pair]
  7. pair)
  8. pair)]
  9. (if (some? r)
  10. #js [node' #js [r cont]]
  11. #js [node' cont])))
  12. #js [root nil])))
Add Comment
Please, Sign In to add comment