Skip to content

Instantly share code, notes, and snippets.

@aaylward
Created October 1, 2017 16:13
Show Gist options
  • Save aaylward/730ddbac7c2be913ec12eae553d6445a to your computer and use it in GitHub Desktop.
Save aaylward/730ddbac7c2be913ec12eae553d6445a to your computer and use it in GitHub Desktop.
(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