Fork me on GitHub
#specter
<
2017-03-16
>
Busy escaping the comfort zone07:03:02

Hey, looking for a way to dissoc all items that are not matched by a select

rauh07:03:08

@narkisr Like this? (sp/setval [sp/ALL (sp/not-selected? sp/LAST odd?)] sp/NONE {:a 0 :b 1})

Busy escaping the comfort zone07:03:56

I think so but my path is based on srange (I want to remove all items except last n)

Busy escaping the comfort zone07:03:56

Ill give it a go and report back

nathanmarz11:03:06

@rauh you can do that more concisely and efficiently with: (setval [MAP-VALS even?] NONE {:a 0 :b 1})

nathanmarz11:03:59

@narkisr you can do that by transforming the srange to be a smaller sequence only containing the last n elements

nathanmarz11:03:19

e.g. (transform (srange 1 5) #(subvec % 2 4) [1 2 3 4 5 6 7 8]) => [1 4 5 6 7 8]

Busy escaping the comfort zone12:03:50

Hey Natan, (transform [MAP-VALS (srange 1 4)] NONE (into (sorted-map) {1 2 3 4 5 6 7 8 9 10})))

Busy escaping the comfort zone12:03:00

Seems to not keep the sorting order

Busy escaping the comfort zone12:03:41

Just realized iv should have used (srange 0 3)

Busy escaping the comfort zone12:03:36

Also not sure how many you get feedback but specter is awesome, I can't imagine writing Clojure without it

nathanmarz13:03:08

@narkisr thanks, glad to hear it