From d53a3c21fd4e4bedd08a1b38973790b75454a3ca Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Mon, 11 Sep 2017 11:22:08 -0400 Subject: [PATCH] Document string navigation. --- List-of-Navigators.md | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/List-of-Navigators.md b/List-of-Navigators.md index 9eb9968..f550575 100644 --- a/List-of-Navigators.md +++ b/List-of-Navigators.md @@ -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)`