VList: Difference between revisions
Content added Content deleted
(→{{header|Component Pascal}}: format comments) |
|||
Line 383: | Line 383: | ||
MODULE RosettaVLists; |
MODULE RosettaVLists; |
||
(** In 2002, Phil Bagwell published "Fast Functional Lists" which introduced VLists as alternatives to Functional Programming's |
(** In 2002, Phil Bagwell published "Fast Functional Lists" which introduced VLists as alternatives to Functional Programming's |
||
ubiquitous linked lists and described Visp (a dialect of Common Lisp) using VLists, but including a "foldr" function, |
ubiquitous linked lists and described Visp (a dialect of Common Lisp) using VLists, but including a "foldr" function, |
||
optimized to use VLists. VLists have the same properties as immutable functional linked lists (including full persistence); but, |
|||
unlike a linked list, with O(1) random access time. The VLists implemented here is based on section 2.1 of that article but has been |
|||
modified to retain the safety features of Component Pascal. |
|||
VLists are referenced through 2 fields: "base" and "offset". A third field "length" reduces the time to determine its length to O(1). |
|||
Methods provided for manipulating VLists are named after their corresponding Visp functions, but follow Component Pascal's case conventions. **) |
Methods provided for manipulating VLists are named after their corresponding Visp functions, but follow Component Pascal's case conventions. **) |