Fork me on GitHub
#specter
<
2018-05-05
>
chromalchemy00:05:52

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?

chromalchemy00:05:04

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)

nathanmarz01:05:46

@chromalchemy that first path is best written as (select-any [(filterer pred) (srange 0 3)] collection)

nathanmarz01:05:10

you could do side effects in a path with something like:

(defn side-effect [f]
  (view (fn [v] (f v) v)))

nathanmarz01:05:20

seems weird to me though to do something like that

chromalchemy02:05:39

@nathanmarz Thank you. I will get to know subselect and select-any.