Created
September 21, 2014 16:34
-
-
Save MichaelDrogalis/0a18c2c6eee0fbd16df7 to your computer and use it in GitHub Desktop.
Converting multi-input streams to Onyx trees.
This file contains hidden or 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 graph-to-onyx-tree [graph] | |
(reduce | |
(fn [workflow root] | |
(if (set? root) | |
(reduce (fn [result input] (assoc result input (get graph root))) workflow root) | |
(assoc workflow root (get graph root)))) | |
{} | |
(keys graph))) | |
(graph-to-onyx-tree {#{:A :B :C} {:D :E} :F {:G :H}}) | |
;;; => {:C {:D :E}, :B {:D :E}, :A {:D :E}, :F {:G :H}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment