Skip to main content
Log in

An efficiency comparison of some representations of purely functional arrays

  • Part II Computer Science
  • Published:
BIT Numerical Mathematics Aims and scope Submit manuscript

Abstract

We describe an efficient representation of purely functional arrays suggested by Holmström and Hughes, here calledversion tree arrays orv-arrays. A collection of arrays is represented by aversion tree where the root array is stored in contiguous memory as usual and every other array is represented as a node that records the difference to its father. Updating is done by adding a new node to the version tree and takes constant time, while the time for subscripting is proportional to the distance to the root. Essential for efficiency is therefore the possibility to reroot the tree without changing the semantics of the subscript operation, i.e. the values that the arrays represent.

We also show howv-arrays can be implemented in Standard ML and compare the efficiency ofv-arrays to other representations, like binary trees, lists and functions, by measuring the execution time of some programs that use sequences.v-arrays turn out to be superior in practice in algorithms that use arrays singlethreadedly and access them randomly.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Similar content being viewed by others

References

  1. H. G. Baker,Shallow binding in Lisp 1.5. Comm. ACM 21 :7.

  2. S. Holmström,How to handle large data structures in functional languages, inProc. of the SERC/Chalmers workshop on Declarative Programming Languages, University College London (1983).

  3. L.-H. Eriksson and M. Rayner,Incorporating mutable arrays into logic programming, inProc. of the 2nd int. Logic Programming Conference, Uppsala (1984).

  4. P. Hudak,A semantic model of reference counting and its abstraction, inProc. of the ACM Symposium on LISP and Functional Programming, Cambridge, Mass., (1986).

  5. P. Hudak and A. Bloss,The aggregate update problem in functional programming systems, in 12th ACM Symp. on Principles of Programming Languages, New Orleans (1985).

  6. J. Hughes,An efficient implementation of purely functional arrays, Dept. of Computer Sciences, Chalmers University of Technology, Göteborg (1985).

    Google Scholar 

  7. R. Milner,The Standard ML Core Language, University of Edinburgh (1985).

  8. A. Mycroft,Abstract Interpretation and Optimizing Transformations for Applicative Programs, Doctoral dissertation, University of Edinburgh (1981).

  9. D. Schmidt,Detecting global variables in denotational specifications, TOPLAS vol. 7, pp. 299–310, (1985).

    Google Scholar 

  10. J. Schwarz,Verifying the safe use of destructive operations in applicative programs, in 3eme Colloque Internat. sur la Programmation, Dunod, Paris (1978).

    Google Scholar 

  11. W. F. Tichy,Design, implementation and evaluation of a revision control system, inProc. of the 6th Int. Conf. on Software Engineering, IEEE, Tokyo, Sept. 1982.

Download references

Author information

Authors and Affiliations

Authors

Additional information

This work has been supported by STU, the Swedish Board for Technical Development.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Aasa, A., Holmström, S. & Nilsson, C. An efficiency comparison of some representations of purely functional arrays. BIT 28, 489–503 (1988). https://doi.org/10.1007/BF01941130

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01941130

CR categories

Navigation