specter

Latest version: 1.1.3
2018-04-16T00:45:44.000138Z

Nathan, new to clojure, needed get-in but will now pursue specter. Can it navigate through ref boundaries in deeply nested combos of maps and vectors?

nathanmarz 2018-04-16T01:18:32.000162Z

@steveh2009 yes, no problem

nathanmarz 2018-04-16T01:19:14.000045Z

for navigating into refs you'd need to make your own navigator, but that is very easy – just use ATOM as an example: https://github.com/nathanmarz/specter/blob/master/src/clj/com/rpl/specter.cljc#L1081

2018-04-16T01:23:31.000042Z

Fantastic. Off to YouTube to see your talks.

tanzoniteblack 2018-04-16T20:40:27.000124Z

Is there a way I can implement take-while via specter? Specifically, I (eventually down a path) have a sequence of items, and I want to take every item up to (and including) a certain value. Example:

[{:id :a} {:id :b} {:id :c} {:id :d}]
;; up to (& including) index: :c
;; ==> [{:id :a} {:id :b} {:id :c}]
current implementation using split-with:
(let [[steps-before steps-after] (split-with #(not= (:id %) :c) [{:id :a} {:id :b} {:id :c} {:id :d}])]
     (concat steps-before (take 1 steps-after)))

nathanmarz 2018-04-16T20:45:12.000148Z

@tanzoniteblack you could do it with srange-dynamic

tanzoniteblack 2018-04-16T20:45:42.000277Z

thanks

nathanmarz 2018-04-16T20:52:23.000595Z

@tanzoniteblack with https://github.com/nathanmarz/specter/issues/236 it could be done more efficiently/directly