Journal of Functional Programming



FUNCTIONAL PEARL

The Zipper


GÉRARD HUET a1
a1 INRIA Rocquencourt, France

Abstract

Almost every programmer has faced the problem of representing a tree together with a subtree that is the focus of attention, where that focus may move left, right, up or down the tree. The Zipper is Huet's nifty name for a nifty data structure which fulfills this need. I wish I had known of it when I faced this task, because the solution I came up with was not quite so efficient or elegant as the Zipper.