Module im::conslist [] [src]

A cons list.

A cons list is a singly linked list built out of 'cons cells,' which are cells containing two values, the left hand value being the head of the list and the right hand value being a reference to the rest of the list, or a Nil value denoting the end of the list.

Structure can be shared between lists (and is reference counted), and append to the front of a list is O(1). Cons cells keep track of the length of the list at the current position, as an extra optimisation, so getting the length of a list is also O(1). Otherwise, operations are generally O(n).

Unless you know you want a ConsList, you might be better off using a List, which has more generically efficient performance characteristics, but which is outperformed by the ConsList if you're usually only operating on the front of the list.

Structs

ConsList

An implementation of immutable proper cons lists.

Iter

Functions

cons

Prepend a value to a list.