Created
October 1, 2017 16:13
-
-
Save aaylward/730ddbac7c2be913ec12eae553d6445a to your computer and use it in GitHub Desktop.
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
(ns meetup) | |
(def myinput { :app1 #{:t1 :t2} :app2 #{:t2 :t3} :app3 #{:t2 :t3 :t4}}) | |
(defn update-table [outputmap table app] | |
(assoc outputmap table (conj (or (outputmap table) #{}) app))) | |
(defn process-tables [outputmap [app tables]] | |
(loop [map outputmap appname app ts tables] | |
(if (empty? ts) | |
map | |
(recur (update-table map (first ts) app) app (rest ts))))) | |
(defn process-apps [app-hash] | |
(loop [items (seq app-hash) output {}] | |
(if (empty? items) | |
output | |
(recur (rest items) (process-tables output (first items)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment