Fork me on GitHub
#specter
<
2016-12-29
>
Busy escaping the comfort zone01:12:58

Hey, looking for a way of selecting items from a Vector using Specter (like srange but for any index), couldn't find a way of doing: (select [ALL <?>] [[1 2 3 4 5] [1 2 3 6 7]]) -> [[2 5] [2 7]]

Busy escaping the comfort zone01:12:12

(select [ALL (multi-path (keypath 1) (keypath 4)) ] rs)

Busy escaping the comfort zone01:12:20

but it flattens out the result

Busy escaping the comfort zone01:12:34

A possible solution might be to use: (transform [ALL (s/collect-one (keypath 0) ) (s/collect-one (keypath 1) )] (fn [a b c] [a b]) rs) which feels a bit akward (I would like to have the ability so select neste sub vectors)

nathanmarz01:12:51

@narkisr you can use subselect

nathanmarz01:12:34

subselect + multi-path should get you the behavior you want

Busy escaping the comfort zone01:12:52

Ok, thanks! ill try to use them

nathanmarz01:12:23

(select [ALL (subselect (multi-path (keypath 1) (keypath 4)))] [[1 2 3 4 5] [1 2 3 6 7]])

Busy escaping the comfort zone02:12:38

BTW is there any reason why indices are not treated like map keys? (since both access assosciative DS)

Busy escaping the comfort zone02:12:52

You need to wrap them using keypath

nathanmarz14:12:03

I just stuck with implementing implicit behavior that's analogous to what clojure already treats as functions

nathanmarz14:12:11

@narkisr namely keywords and sets

nathanmarz14:12:31

you could always implement that yourself if you want it, see ImplicitNav