Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

September 14, 2011

Clojure Zippers

Filed under: Clojure,Functional Programming — Patrick Durusau @ 7:02 pm

Clojure Zippers

Loke VanderHart on zippers in Clojure.

From the website:

An introduction to the Clojure zip data structure, which supports fully functional tree navigation and editing. Includes a discussion of how to use the data structure effectively, as well as an overview of its performance characteristics.

I would supplement this presentation with:

“Editing” trees in Clojure with clojure.zip by Brian Marick.

Zippers – Functional Tree Editing (its under Other Included Libraries)

From the webpage:

Clojure includes purely functional, generic tree walking and editing, using a technique called a zipper (in namespace zip) . For background, see the paper by Huet. A zipper is a data structure representing a location in a hierarchical data structure, and the path it took to get there. It provides down/up/left/right navigation, and localized functional ‘editing’, insertion and removal of nodes. With zippers you can write code that looks like an imperative, destructive walk through a tree, call root when you are done and get a new tree reflecting all the changes, when in fact nothing at all is mutated – it’s all thread safe and shareable.

Oh, and the library documentation: API for Clojure.zip

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress