Next: Mutation, Previous: Getters and setters, Up: rope transpose API [Contents][Index]
In this section we document various procedures that move around the
<rope-transpose> pointer. For example, here is how to walk the
rope and generate its leaves in an
SRFI-41 stream:
(use-modules (srfi srfi-41))
(define r (cons->rope '(("w" . "o") "w" . "!")))
(define (rope->stream r)
(stream-unfold rope-transpose-node
(compose not null?)
rope-transpose-next
(rope-transpose-from-index r 0)))
(stream->list (rope->stream r))
⇒ ("w" "o" "w" "!")
Example 2.22: Walking the rope and collecting its leaves in a stream.
Ascends the current node of rope-transpose until it is a left (or right) child of its parent according to right-child?. If such a node is not found, the procedure stops at root and returns it.
Descend to the left child of the current node of rope-transpose.
A repeat descend to the left child until a leaf is met.
Descend to the right child of the current node of rope-transpose.
A repeat descend to the right child until a leaf is met.
The next leaf from where rope-transpose points (i.e. to the right of the node pointed to by rope-ranspose), or nil.
The previous leaf from where rope-transpose points (i.e. to the left of the node pointed to by rope-ranspose), or nil.
Next: Mutation, Previous: Getters and setters, Up: rope transpose API [Contents][Index]