Find location of node in tree using Clojure zippers -


i have tree of unknown structure. first, want find node containing string of text, "something". then, after identifying string's location in tree, want update different node relative string's location. data nested map several branches of lists.

is possible zippers?

i've studied approach editing trees: http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/. problem is, don't beforehand know location of string.

yes! kind of task zippers designed for.

  • repeatedly call zip/next until find node looking for.
  • then call zip/path find out relative root.
  • then call zip/up, zip/down, zip/left etc node modify.
  • update node
  • call zip/root new map containing these changes.

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -