A random-access list is a data structure that supports O(1) cons/head/tail (like a standard linked list), plus index/update in O(log n) time.
I first heard about it in Purely Functional Data Structures, which contains a couple implementations in the chapter on numerical representations. Probably due to this prominent feature, there are three packages that implement the interface, each with a shorter name than the ones that came before it:
- random-access-list: Random-access lists in Haskell
- ralist: Random access list with a list compatible interface.
- ral: Random access lists
… but I can’t say I’ve ever actually reached for this data structure!
From the chapter,
Skew binary random-access lists are a good choice for applications that take advantage of both the list-like aspects and the array-like aspects of random-access lists. Although there are better implementations of lists, and better implementations of (persistent) arrays, none are better at both.
I’m curious, what are some examples of such applications? Thanks!