From 228a949ac1b3f2618ca1bdc057db266663d5c6ec Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Wed, 27 May 2015 01:05:15 -0400 Subject: [PATCH] update README --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 81446d0..68af581 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ user> (update [ALL (collect-one :b) :a even?] The update function receives as arguments all the collected values followed by the navigated to value. So in this case `+` receives the value of the :b key followed by the value of the :a key, and the update is performed to :a's value. -The three built-in ways for collecting values are `VAL`, `collect`, and `collect-one`. `VAL` just adds whatever element it's currently on to the value list, while `collect` and `collect-one` take in a selector to navigate to the desired value. `collect` works just like `select` by finding a sequence of values, while `collect-one` expects to only navigate to a single value. +The four built-in ways for collecting values are `VAL`, `collect`, `collect-one`, and `putval`. `VAL` just adds whatever element it's currently on to the value list, while `collect` and `collect-one` take in a selector to navigate to the desired value. `collect` works just like `select` by finding a sequence of values, while `collect-one` expects to only navigate to a single value. Finally, `putval` adds an external value into the collected values list. To make your own selector, implement the `StructurePath` protocol which looks like: @@ -163,6 +163,14 @@ user> (update [ALL LAST] {:b 2 :a 0} ``` +Increment the value for :a key by 10: +```clojure +user> (update [:a (putval 10)] + + + {:a 1 :b 3}) +{:b 3 :a 11} +``` + Get every number divisible by 3 out of a sequence of sequences: ```clojure user> (select [ALL ALL #(= 0 (mod % 3))]