I had nearly forgotten all of the very convenient functions in the Medley
library <https://github.com/weavejester/medley> until I was reminded by a
small mention in the Clojure Cheatsheet
<http://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html>.
It allows you to very easily remove nil values from a list of maps and
merge them all together:

(ns clj.core
  (:require [tupelo.core :as t]
            [medley.core :as medley] ))
(t/refer-tupelo)

(def src [ {:a 1 :b nil}
           {:c 3 }
           {:d nil :e 5 } ] )

(spyx (apply glue src))
;=> (apply glue src) => {:a 1, :b nil, :c 3, :d nil, :e 5}

(spyx (medley/remove-vals nil? {:d nil :e 5}))
;=> (medley/remove-vals nil? {:d nil, :e 5}) => {:e 5}

(def result (medley/remove-vals
              nil?
              (apply t/glue src)))
(spyx result)
;=> result => {:a 1, :c 3, :e 5}


​
​Alan​

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to