This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-13
Channels
- # beginners (42)
- # boot (33)
- # cider (4)
- # clara (1)
- # cljs-dev (2)
- # clojars (3)
- # clojure (207)
- # clojure-boston (1)
- # clojure-france (3)
- # clojure-india (7)
- # clojure-miami (1)
- # clojure-nl (8)
- # clojure-poland (13)
- # clojure-russia (102)
- # clojure-spec (22)
- # clojure-uk (37)
- # clojureremote (15)
- # clojurescript (229)
- # cursive (9)
- # datomic (1)
- # emacs (7)
- # figwheel (2)
- # funcool (1)
- # garden (1)
- # hoplon (7)
- # jobs (12)
- # jobs-discuss (27)
- # juxt (2)
- # leiningen (6)
- # luminus (9)
- # lumo (18)
- # off-topic (3)
- # onyx (9)
- # re-frame (54)
- # reagent (5)
- # remote-jobs (3)
- # ring (3)
- # rum (3)
- # specter (28)
- # yada (30)
anyone around?
first and foremost … specter is awesome
now that I have that out of the way
thanks
I need to transform this data structure (I’ve elided unnecessary bits for now):
(def plans
{:plans '({:planId "1"
:disbursements ({:history ({:amount "1" :disbursementDate "2017-01-01"}
{:amount "1" :disbursementDate "2017-01-01"}
{:amount "2" :disbursementDate "2017-02-01"}
{:amount "3" :disbursementDate "2017-03-01"})})})})
by removing duplicate entries from the :history
list
this basically does what I want:
(transform [:plans ALL #(= "1" (:planId %)) :disbursements ALL :history]
dedupe
plans)
but what if I want a predicate to ensure that I’m only dedupe
ing entries from January, i.e. “2017-01-01”
gonna have to do it manually for now in your transform fn
it's possible subselect
could be extended to support that
so you could do:
(transform [:plans ALL #(= "1" (:planId %)) :disbursements ALL :history (filterer :disbursementDate #(= % “2017-01-01”))]
dedupe
plans)
right now subselect
/`filterer` require the output sequence to be the same size as the input
the logic change would be to fill in removed entires with NONE
to trigger removal
that would be a good issue to open on github
ah … cool
Thank you for the quick response … I’ll play around a bit to make sure I completely understand, then I’ll submit an issue
actually it's fine
I was curious so I just implemented it
@tankthinks https://github.com/nathanmarz/specter/commit/be30e46960c879d6177d8ab8c2d3f4450bab0095
quite elegant I think
so … uh … you’re welcome?
thanks again @nathanmarz, not sure how I would have done that without specter … cheers!