A sequence is an object holding a list of elements which support the following operations:
- adding an element to the left or the right in time and space O(1)
- taking an element from the left or the right in time and space O(1)
- removing a previously added element from a sequence in time and space O(1)
- removing an element while the sequence is being transversed.
Type of a sequence holding values of type 'a
Type of a node holding one value of type 'a in a sequence
Operation on nodes
Removes a node from the sequence it is part of. It does nothing if the node has already been removed.
Operations on sequence
create () creates a new empty sequence
add_l x s adds x to the left of the sequence s
Sequence iterators
Note: it is OK to remove a node while traversing a sequence
Sourceval iter_l : ('a -> unit) -> 'a t -> unit iter_l f s applies f on all elements of s starting from the left
Sourceval fold_l : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b fold_l f s is:
fold_l f s x = f en (... (f e2 (f e1 x)))
where e1, e2, ..., en are the elements of s