Mutable sequence of elements
A sequence is an object holding a list of elements which support the following operations:
Type of a sequence holding values of type 'a
Type of a node holding one value of type 'a
in a sequence
Removes a node from the sequence it is part of. It does nothing if the node has already been removed.
Returns the number of elemenets in the given sequence. This is a
O(n) operation where n
is the number of elements in the
sequence.
Exception raised by take_l
and tale_s
and when the sequence
is empty
take_l x s
remove and returns the leftmost element of s
Empty
if the sequence is empty
take_l x s
remove and returns the rightmost element of s
Empty
if the sequence is empty
take_opt_l x s
remove and returns Some x
where x
is the
leftmost element of s
or None
if s
is empty
take_opt_l x s
remove and returns Some x
where x
is the
rightmost element of s
or None
if s
is empty
Note: it is OK to remove a node while traversing a sequence
iter_l f s
applies f
on all elements of s
starting from
the left
iter_l f s
applies f
on all elements of s
starting from
the right
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
fold_r f s
is:
fold_r f s x = f e1 (f e2 (... (f en x)))
where e1
, e2
, ..., en
are the elements of s