I have
- a Clojure, let him call it
dom , a tree of vectors and maps of indefinite depth; - the specific node in it, let's call it
focus node, called the path to the tree: a sequence of keys, for example, which you could imagine get-in .
I will solve a focused node in one function, and I want to somehow present this choice of a focused node in a way that can be passed to another function in such a way that it does not violate immutability and is not in conflict with stable Clojure data structures.
When I cross a tree, I want to relate to the focus node differently: for example, if I printed the tree, I could print the focus node in bold .
If I used C or Java, I could save a pointer / link to the focus node, which I could compare with the current node when I was crossing the tree. I don't think the right way to do this in Clojure is: it feels hacky, and I'm sure there is some way to do it that uses Clojure's robust data structures.
The solution should work in Clojure and ClojureScript.
Possible options:
I am sure this is a common problem. Is there a standard solution?
source share