This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-05
Channels
- # architecture (3)
- # aws (4)
- # beginners (100)
- # boot (14)
- # cider (59)
- # cljs-dev (1)
- # cljsrn (24)
- # clojure (53)
- # clojure-dev (58)
- # clojure-italy (2)
- # clojure-spec (1)
- # clojure-uk (25)
- # clojurescript (7)
- # cryogen (1)
- # cursive (1)
- # datomic (9)
- # dirac (9)
- # duct (3)
- # off-topic (52)
- # om-next (3)
- # onyx (42)
- # portkey (28)
- # re-frame (3)
- # reagent (11)
- # rum (3)
- # shadow-cljs (12)
- # specter (7)
- # tools-deps (18)
- # vim (1)
- # yada (4)
I am trying to do this:
(select (srange 0 3) (select [ALL (selected? pred)] collection))
Is there a way to pop back up to a view of the collection before selecting each node through ALL, idiomatically in one path, instead of using two functions and nesting one? I'm assuming there would be a transducer-like performance benefit to this, am I right?
Alternatively, can srange
be used after ALL
to still filter the root nodes in the collection?Also, is there a way to do side effects in the middle of a compound path like [path1 (side-effect-fn) path2]
Or would it better to collect the necessary value for the side effect, then use a transform fn:
(transform [path1 collect path2] #(do (side-effect-fn %1) (main-fn %2)) collection)
@chromalchemy that first path is best written as (select-any [(filterer pred) (srange 0 3)] collection)
the definition of filterer
is instructive: https://github.com/nathanmarz/specter/blob/master/src/clj/com/rpl/specter.cljc#L1137
you could do side effects in a path with something like:
(defn side-effect [f]
(view (fn [v] (f v) v)))
seems weird to me though to do something like that
@nathanmarz Thank you. I will get to know subselect
and select-any
.