This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-14
Channels
- # beginners (31)
- # boot (9)
- # cider (10)
- # cljs-dev (9)
- # cljsrn (16)
- # clojure (222)
- # clojure-austin (4)
- # clojure-france (13)
- # clojure-italy (21)
- # clojure-nl (2)
- # clojure-russia (71)
- # clojure-spec (9)
- # clojure-uk (39)
- # clojurescript (50)
- # cursive (16)
- # datomic (69)
- # dirac (2)
- # figwheel (1)
- # graphql (19)
- # hoplon (4)
- # jobs (1)
- # klipse (3)
- # leiningen (4)
- # liberator (3)
- # luminus (9)
- # lumo (9)
- # off-topic (3)
- # om (21)
- # onyx (11)
- # parinfer (2)
- # pedestal (8)
- # planck (19)
- # re-frame (17)
- # reagent (12)
- # remote-jobs (1)
- # ring-swagger (3)
- # spacemacs (17)
- # specter (23)
- # sql (1)
- # unrepl (64)
- # untangled (19)
- # yada (5)
looking for a 'stateful collector', for merging a sequence of values with a value within a nested structure
something like this:
(use 'com.rpl.specter)
(def o {:a {:x 1}
:b {:x 1}
:c {:x 1}})
(def i (range 1 10))
(defcollector putseqval
[a]
(collect-val
[this structure]
(let [v (first @a)]
(swap! a rest)
v)))
(transform
[MAP-VALS MAP-VALS (putseqval (atom i))]
+
o);; => {:a {:x 2}, :b {:x 3}, :c {:x 4}}
@tcoupland use subselect
(setval (subselect MAP-VALS MAP-VALS) [2 3 4] o)
@tcoupland what do you mean?
i want to execute a function (+) on the value in the datastructure (o) and values from the sequence (i)
transform
on the subselect will be on the sequence of values
so you can combine the two sequences easily
(transform (subselect MAP-VALS MAP-VALS) (fn [s] (map + s [2 3 4])) o)
i recommend toying around with the size of transformed sequence to fully understand its behavior
(transform [(subselect MAP-VALS (collect FIRST FIRST) MAP-VALS)]
(fn [fnd] (prn (map (fn [[k v] r] (str k v r)) fnd i)))
o)
Wrong number of args (2) passed to:
specter/fn--38572/fn/reify--38574/fn--38579
AFn.java: 429 clojure.lang.AFn/throwArity
AFn.java: 36 clojure.lang.AFn/invoke
AFn.java: 156 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 652 clojure.core/apply
impl.cljc: 406 com.rpl.specter.impl$terminal_STAR_/invokeStatic
impl.cljc: 403 com.rpl.specter.impl$terminal_STAR_/invoke
impl.cljc: 413 com.rpl.specter.impl$compiled_transform_STAR_$fn__36780/invoke
specter.cljc: 673 com.rpl.specter$reify__38443$next_fn__38449/invoke
the prn in the transform function get's fired and looks right, but then the exception happens
@tcoupland don't use value collection in subselect
i'll put a note about that in its documentation