Document string navigation.

This commit is contained in:
Michael Fogleman 2017-09-11 11:22:08 -04:00
parent cc79aa51be
commit d53a3c21fd

View file

@ -134,6 +134,15 @@
([:foo :baz] [:foo :bar])
```
As of Specter 1.0.0, `BEGINNING` can now work with strings. It navigates to or transforms substrings.
```clojure
=> (select-any BEGINNING "abc")
""
=> (setval BEGINNING "b" "a")
"ba"
```
## DISPENSE
_Added in 0.12.0_
@ -164,6 +173,15 @@ Drops all collected values for subsequent navigation.
([:foo :bar] [:foo :baz])
```
As of Specter 1.0.0, `END` can now work with strings. It navigates to or transforms substrings.
```clojure
=> (select-any END "abc")
""
=> (setval END "b" "a")
"ab"
```
## FIRST
`FIRST` navigates to the first element of a collection. If the collection is a map, returns a key-value pair `[key value]`. If the collection is empty, navigation stops.
@ -181,6 +199,15 @@ nil
nil
```
As of Specter 1.0.0, `FIRST` can now work with strings. It navigates to or transforms characters.
```clojure
=> (select-any FIRST "abc")
\a
=> (setval FIRST \q "abc")
"qbc"
```
## INDEXED-VALS
`INDEXED-VALS` navigates to [index elem] pairs for each element in a sequence. Transforms of index move element at that index to the new index, shifting other elements in the sequence. Indices seen during transform take into account any shifting from prior sequence elements changing indices.
@ -211,6 +238,15 @@ nil
nil
```
As of Specter 1.0.0, `LAST` can now work with strings. It navigates to or transforms characters.
```clojure
=> (select-any LAST "abc")
\c
=> (setval LAST "q" "abc")
"abq"
```
## MAP-KEYS
`MAP-KEYS` navigates to every key in a map. `MAP-VALS` is more efficient than `[ALL FIRST]`.
@ -802,6 +838,17 @@ IndexOutOfBoundsException
(0 1 4)
```
As of Specter 1.0.0, `srange` can now work with strings. It navigates to or transforms substrings.
```clojure
=> (select-any (srange 1 3) "abcd")
"bc"
=> (setval (srange 1 3) "" "abcd")
"ad"
=> (setval [(srange 1 3) s/END] "x" "abcd")
"abcxd"
```
## srange-dynamic
`(srange-dynamic start-fn end-fn)`