From 4b9a415eff7818bbeb55b727dada6976820be692 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Tue, 22 Sep 2015 10:37:55 -0400 Subject: [PATCH] add example of keypath to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d33812f..a38e4b1 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,14 @@ user> (select (walker number?) [2 1 2 1 2 6 7 4] ``` +`keypath` can be used to navigate via non-keyword keys: + +```clojure +user> (select [(keypath "a") (keypath "b")] + {"a" {"b" 10}}) +[10] +``` + When doing more involved transformations, you often find you lose context when navigating deep within a data structure and need information "up" the data structure to perform the transformation. Specter solves this problem by allowing you to collect values during navigation to use in the transform function. Here's an example which transforms a sequence of maps by adding the value of the :b key to the value of the :a key, but only if the :a key is even: ```clojure