Skip to content

Instantly share code, notes, and snippets.

@MichaelDrogalis
Created September 21, 2014 16:34
Show Gist options
  • Save MichaelDrogalis/0a18c2c6eee0fbd16df7 to your computer and use it in GitHub Desktop.
Save MichaelDrogalis/0a18c2c6eee0fbd16df7 to your computer and use it in GitHub Desktop.
Converting multi-input streams to Onyx trees.
(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