rewrite-clj

2023-11-17T20:50:35.319449Z

if i have a list node (1 2 3 4 5) and i've called (-> zloc z/down z/right z/right), i'm at 3. how do i take 3, 4, and 5 as a sequence?

lread 2023-11-17T23:20:14.965919Z

Hi @nbtheduke! Here's one way:

(require '[rewrite-clj.zip :as z])

(def zloc (z/of-string "(1 2 3 4 5)"))

(some->> zloc
         z/down
         z/right
         z/right
         (iterate z/right)
         (take-while identity)
         (map z/node))
;; => ({:value 3, :string-value "3"}
;;     {:value 4, :string-value "4"}
;;     {:value 5, :string-value "5"})
Does that work for you?

👍 1
2023-11-17T23:26:20.478799Z

That’s great, thank you

lread 2023-11-17T23:36:19.851199Z

Always a pleasure @nbtheduke!