This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-29
Channels
- # adventofcode (4)
- # beginners (113)
- # boot (165)
- # cider (192)
- # cljsrn (82)
- # clojure (148)
- # clojure-austin (6)
- # clojure-russia (22)
- # clojure-spec (45)
- # clojure-uk (19)
- # clojurescript (153)
- # core-async (5)
- # cursive (7)
- # datomic (2)
- # defnpodcast (2)
- # emacs (1)
- # hoplon (617)
- # instaparse (10)
- # lein-figwheel (19)
- # luminus (2)
- # off-topic (12)
- # om (3)
- # onyx (36)
- # pedestal (1)
- # protorepl (43)
- # re-frame (8)
- # ring (7)
- # specter (17)
- # testing (2)
- # untangled (117)
- # yada (12)
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]]
There is multi-path
(select [ALL (multi-path (keypath 1) (keypath 4)) ] rs)
but it flattens out the result
[2 5 2 7] [
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)
@narkisr you can use subselect
subselect
+ multi-path
should get you the behavior you want
Ok, thanks! ill try to use them
(select [ALL (subselect (multi-path (keypath 1) (keypath 4)))] [[1 2 3 4 5] [1 2 3 6 7]])
BTW is there any reason why indices are not treated like map keys? (since both access assosciative DS)
You need to wrap them using keypath
I just stuck with implementing implicit behavior that's analogous to what clojure already treats as functions
@narkisr namely keywords and sets
you could always implement that yourself if you want it, see ImplicitNav
Got it, thanks