Next: Mutation, Previous: Predicates, Up: rope transpose API   [Contents][Index]


2.12.4 Navigation ¶

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.

Procedure: rope-transpose-ascend rope-transpose right-child? ¶

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.

Procedure: rope-transpose-left rope-transpose ¶

Descend to the left child of the current node of rope-transpose.

Procedure: rope-transpose-left* rope-transpose ¶

A repeat descend to the left child until a leaf is met.

Procedure: rope-transpose-right rope-transpose ¶

Descend to the right child of the current node of rope-transpose.

Procedure: rope-transpose-right* rope-transpose ¶

A repeat descend to the right child until a leaf is met.

Procedure: rope-transpose-next rope-transpose ¶

The next leaf from where rope-transpose points (i.e. to the right of the node pointed to by rope-ranspose), or nil.

Procedure: rope-transpose-previous rope-transpose ¶

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: Predicates, Up: rope transpose API   [Contents][Index]