From 12472fa5996aedbe7a9dd6762a7f1074b33dad0e Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Mon, 11 Sep 2017 10:06:17 -0400 Subject: [PATCH] Document INDEXED-VALS. --- List-of-Navigators.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/List-of-Navigators.md b/List-of-Navigators.md index 49120b5..a4358ff 100644 --- a/List-of-Navigators.md +++ b/List-of-Navigators.md @@ -9,6 +9,7 @@ - [DISPENSE](#dispense) - [END](#end) - [FIRST](#first) + - [INDEXED-VALS](#indexed-vals) - [LAST](#last) - [MAP-KEYS](#map-keys) - [MAP-VALS](#map-vals) @@ -154,6 +155,19 @@ nil nil ``` +## 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. + +```clojure +=> (select [INDEXED-VALS] [1 2 3 4 5]) +[[0 1] [1 2] [2 3] [3 4] [4 5]] +=> (setval [INDEXED-VALS FIRST] 0 [1 2 3 4 5]) +[5 4 3 2 1] +=> (setval [INDEXED-VALS FIRST] 1 [1 2 3 4 5]) +[1 5 4 3 2] +``` + ## LAST `LAST` navigates to the last element of a collection. If the collection is a map, returns a key-value pair `[key value]`. If the collection is empty, navigation stops.