Skip to content

Instantly share code, notes, and snippets.

@AlexWheeler
Created January 8, 2017 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexWheeler/7d6a97978e51a036367de42936da8fae to your computer and use it in GitHub Desktop.
Save AlexWheeler/7d6a97978e51a036367de42936da8fae to your computer and use it in GitHub Desktop.
(defn- copy-nil-vals [[k v]]
(if (nil? v)
{k k}
{k v}))
(defn column-vals [column-mappings]
(->> column-mappings
(map #(select-keys % [:value :mapped_value]))
(map vals)
(map #(apply hash-map %))
(apply merge)
(map copy-nil-vals)
(apply merge)))
@AlexWheeler
Copy link
Author

AlexWheeler commented Jan 8, 2017

(column-vals [{:value "h1" :mapped_value "header1" :value "h2" :mapped_value nil}])

should return

{"h1" "header1" "h2" "h2"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment