Hostname: page-component-76fb5796d-vvkck Total loading time: 0 Render date: 2024-04-27T01:51:52.733Z Has data issue: false hasContentIssue false

A new method for functional arrays

Published online by Cambridge University Press:  01 September 1997

MELISSA E. O'NEILL
Affiliation:
School of Computer Science, Simon Fraser University, Canada
F. WARREN BURTON
Affiliation:
School of Computer Science, Simon Fraser University, Canada
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Arrays are probably the most widely used data structure in imperative programming languages, yet functional languages typically only support arrays in a limited manner, or prohibit them entirely. This is not too surprising, since most other mutable data structures, such as trees, have elegant immutable analogues in the functional world, whereas arrays do not. Previous attempts at addressing the problem have suffered from one of three weaknesses, either that they don't support arrays as a persistent data structure (unlike the functional analogues of other imperative data structures), or that the range of operations is too restrictive to support some common array algorithms efficiently, or that they have performance problems. Our technique provides arrays as a true functional analogue of imperative arrays with the properties that functional programmers have come to expect from their data structures. To efficiently support array algorithms from the imperative world, we provide O(1) operations for single-threaded array use. Fully persistent array use can also be provided at O(1) amortized cost, provided that the algorithm satisfies a simple requirement as to uniformity of access. For those algorithms which do not access the array uniformly or single-threadedly, array reads or updates take at most O(log n) amortized time, where n is the size of the array. Experimental results indicate that the overheads of our technique are acceptable in practice for many applications.

Type
Research Article
Copyright
© 1997 Cambridge University Press
Supplementary material: Link

O'neill Supplementary Material

Link
Submit a response

Discussions

No Discussions have been published for this article.