Re: Love the Medley library :)

2016-10-14 Thread Colin Yates
Thanks for the prompt to look at that again. I am not ashamed to say
that after doing Clojure full-time for years now, I still find value
in seeing other people's project.clj let alone their actual code :-).

On 14 October 2016 at 04:17, Alan Thompson  wrote:
> I had nearly forgotten all of the very convenient functions in the Medley
> library until I was reminded by a small mention in the Clojure Cheatsheet.
> 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.

-- 
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.


Love the Medley library :)

2016-10-13 Thread Alan Thompson
I had nearly forgotten all of the very convenient functions in the Medley
library  until I was reminded by a
small mention in the Clojure Cheatsheet
.
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.