Skip to main content

The Random Access Zipper

Simple, Persistent Sequences

  • Conference paper
  • First Online:
Trends in Functional Programming (TFP 2016)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10447))

Included in the following conference series:

  • 298 Accesses

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    In short, these levels represent the heights of uniformly randomly chosen nodes in a full, balanced binary tree. See Sect. 3.

References

  1. AdelsonVelskii, M., Landis, E.M.: An algorithm for the organization of information. Technical report, DTIC Document (1963)

    Google Scholar 

  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. Bayer, R.: Symmetric binary B-trees: data structure and maintenance algorithms. Acta Inf. 1, 290–306 (1972)

    Article  MathSciNet  Google Scholar 

  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). https://doi.org/10.1007/3-540-45749-6_17

    Chapter  MATH  Google Scholar 

  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. 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. 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. Hinze, R., Paterson, R.: Finger trees: a simple general-purpose data structure. J. Funct. Program. 16(2), 197–217 (2006)

    Article  MathSciNet  Google Scholar 

  9. Huet, G.: The zipper. J. Funct. Program. 7, 549–554 (1997)

    Article  MathSciNet  Google Scholar 

  10. OCaml Batteries Team: OCaml batteries included. https://github.com/ocaml-batteries-team/batteries-included. Accessed 12 July 2016

  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). https://doi.org/10.1007/3-540-51542-9_36

    Chapter  Google Scholar 

  12. Pugh, W., Teitelbaum, T.: Incremental computation via function caching. In: POPL (1989)

    Google Scholar 

  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. Stucki, N., Rompf, T., Ureche, V., Bagwell, P.: RRB vector: a practical general purpose immutable sequence. In: ICFP 2015 (2015)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kyle Headley .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Headley, K., Hammer, M.A. (2019). The Random Access Zipper. In: Van Horn, D., Hughes, J. (eds) Trends in Functional Programming. TFP 2016. Lecture Notes in Computer Science(), vol 10447. Springer, Cham. https://doi.org/10.1007/978-3-030-14805-8_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-14805-8_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-14804-1

  • Online ISBN: 978-3-030-14805-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics