Unicode ropes
Type of unicode ropes.
Exception raised when trying to access a character which is outside the bounds of a rope.
make length char creates a rope of length length containing
only char.
init n f returns the contenation of singleton (f 0),
singleton (f 1), ..., singleton (f (n - 1)).
rev_init n f returns the contenation of singleton (f (n -
1)), ..., singleton (f 1), singleton (f 0).
singleton ch creates a rope of length 1 containing only
ch.
of_string str creates a rope from a string. The string must be
UTF-8 encoded and is validated. Note that str must not be
modified after this operation, if you intend to do so you must
copy it before passing it to of_string.
get str rope returns the character at index idx in
rope.
iter f rope applies f on all characters of rope starting
from the left.
rev_iter f rope applies f an all characters of rope
starting from the right.
fold f rope acc applies f on all characters of rope
starting from the left, accumulating a value.
rev_fold f rope acc applies f on all characters of rope
starting from the right, accumulating a value.
map f rope maps all characters of rope with f.
rev_map f str maps all characters of rope with f in
reverse order.
Note: for all of the following functions, the leaves must absolutely not be modified.
Type of zippers. A zipper allow to naviguate in a rope in a
convenient and efficient manner. Note that a zipper points to
a position between two characters, not to a character, so in a
rope of length len there is len + 1 positions.
next zipper returns the code point at the right of the
zipper and a zipper to the next position. It raises
Out_of_bounds if the zipper points to the end of the
rope.
prev zipper returns the code point at the left of the
zipper and a zipper to the previous position. It raises
Out_of_bounds if the zipper points to the beginning of the
rope.
find_f f zip search forward for a character to satisfy
f. It returns a zipper pointing to the left of the first
character to satisfy f, or a zipper pointing to the end of
the rope if no such character exists.