The Random Access Zipper

Simple, Persistent Sequences
  • Kyle HeadleyEmail author
  • Matthew A. Hammer
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10447)


We introduce the Random Access Zipper (RAZ), a simple, persistent data structure for editable sequences. The RAZ combines the structure of a zipper with that of a tree: like a zipper, edits at the cursor require constant time; by leveraging tree structure, relocating the edit cursor in the sequence requires log time. While existing data structures provide these time bounds, none do so with the same simplicity and brevity of code as the RAZ. The simplicity of the RAZ provides the opportunity for more programmers to extend the structure to their own needs, and we provide some suggestions for how to do so.


  1. 1.
    AdelsonVelskii, M., Landis, E.M.: An algorithm for the organization of information. Technical report, DTIC Document (1963)Google Scholar
  2. 2.
    Aragon, C.R., Seidel, R.: Randomized search trees. In: 30th Annual Symposium on Foundations of Computer Science, Research Triangle Park, North Carolina, USA, 30 October–1 November 1989, pp. 540–545 (1989)Google Scholar
  3. 3.
    Bayer, R.: Symmetric binary B-trees: data structure and maintenance algorithms. Acta Inf. 1, 290–306 (1972)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Bender, M.A., Cole, R., Demaine, E.D., Farach-Colton, M., Zito, J.: Two simplified algorithms for maintaining order in a list. In: Möhring, R., Raman, R. (eds.) ESA 2002. LNCS, vol. 2461, pp. 152–164. Springer, Heidelberg (2002). Scholar
  5. 5.
    Dietz, P.F., Sleator, D.D.: Two algorithms for maintaining order in a list. In: Proceedings of the 19th Annual ACM Symposium on Theory of Computing, New York, USA, pp. 365–372 (1987)Google Scholar
  6. 6.
    Hammer, M.A., et al.: Incremental computation with names. In: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, Part of SPLASH 2015, Pittsburgh, PA, USA, 25–30 October 2015, pp. 748–766 (2015)Google Scholar
  7. 7.
    Hammer, M.A., Khoo, Y.P., Hicks, M., Foster, J.S.: Adapton: composable, demand-driven incremental computation. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2014, Edinburgh, United Kingdom, 09–11 June 2014, p. 18 (2014)Google Scholar
  8. 8.
    Hinze, R., Paterson, R.: Finger trees: a simple general-purpose data structure. J. Funct. Program. 16(2), 197–217 (2006)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Huet, G.: The zipper. J. Funct. Program. 7, 549–554 (1997)MathSciNetCrossRefGoogle Scholar
  10. 10.
    OCaml Batteries Team: OCaml batteries included. Accessed 12 July 2016
  11. 11.
    Pugh, W.: Skip lists: a probabilistic alternative to balanced trees. In: Dehne, F., Sack, J.-R., Santoro, N. (eds.) WADS 1989. LNCS, vol. 382, pp. 437–449. Springer, Heidelberg (1989). Scholar
  12. 12.
    Pugh, W., Teitelbaum, T.: Incremental computation via function caching. In: POPL (1989)Google Scholar
  13. 13.
    Sleator, D.D., Tarjan, R.E.: Self-adjusting binary trees. In: Proceedings of the 15th Annual ACM Symposium on Theory of Computing, Boston, Massachusetts, USA, 25–27 April 1983, pp. 235–245 (1983)Google Scholar
  14. 14.
    Stucki, N., Rompf, T., Ureche, V., Bagwell, P.: RRB vector: a practical general purpose immutable sequence. In: ICFP 2015 (2015)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.University of Colorado BoulderBoulderUSA

Personalised recommendations