Link to navigators across docs.
This commit is contained in:
parent
2fdb81823e
commit
bad2cb5265
1 changed files with 4 additions and 4 deletions
|
|
@ -232,7 +232,7 @@ You want to recursively navigate this data structure and add a key-value pair to
|
||||||
{:a {:b {:c 1, :X 0}, :d 2, :X 0}, :e {:f 3, :g 4, :X 0}, :X 0}
|
{:a {:b {:c 1, :X 0}, :d 2, :X 0}, :e {:f 3, :g 4, :X 0}, :X 0}
|
||||||
```
|
```
|
||||||
|
|
||||||
`MAP-NODES` illustrates how to combine recursive paths with `continue-then-stay`, which navigates to the provided path and then to the current element. This should also point to how you might use recursive paths with `stay-then-continue`, which navigates to the current element and then to the provided path.
|
`MAP-NODES` illustrates how to combine recursive paths with `[continue-then-stay](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#continue-then-stay)`, which navigates to the provided path and then to the current element. This should also point to how you might use recursive paths with `[stay-then-continue](https://github.com/nathanmarz/specter/wiki/List-of-Navigators#stay-then-continue)`, which navigates to the current element and then to the provided path.
|
||||||
|
|
||||||
## Find the "index route" of a value within a data structure
|
## Find the "index route" of a value within a data structure
|
||||||
|
|
||||||
|
|
@ -244,9 +244,9 @@ This example comes from [a Stack Overflow question](https://stackoverflow.com/qu
|
||||||
(if-path sequential?
|
(if-path sequential?
|
||||||
[INDEXED-VALS
|
[INDEXED-VALS
|
||||||
(if-path [LAST (pred= v)]
|
(if-path [LAST (pred= v)]
|
||||||
FIRST
|
FIRST
|
||||||
[(collect-one FIRST) LAST p])]))
|
[(collect-one FIRST) LAST p])]))
|
||||||
ret (select-first walker data)]
|
ret (select-first walker data)]
|
||||||
(if (or (vector? ret) (nil? ret)) ret [ret])))
|
(if (or (vector? ret) (nil? ret)) ret [ret])))
|
||||||
#'playground.specter/find-index-route
|
#'playground.specter/find-index-route
|
||||||
=> (find-index-route :my-key '(1 2 :my-key))
|
=> (find-index-route :my-key '(1 2 :my-key))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue