Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn tree-seq [branch? children root]
- (eduction (take-while some?) (map #(aget % 0))
- (iterate (fn [[node pair]]
- (when-some [[[node' & r] cont] (if (branch? node)
- (if-some [cs (not-empty (children node))]
- #js [cs pair]
- pair)
- pair)]
- (if (some? r)
- #js [node' #js [r cont]]
- #js [node' cont])))
- #js [root nil])))
Add Comment
Please, Sign In to add comment