Next: , Previous: , Up: rope API   [Contents][Index]


2.7 Subropes

Procedure: subrope rope start [end]

Obtain the subrope of rope beginning at start and ending at end (default: the rope length.) The subrope shares all nodes (internal and leaves) except potentially the extremal nodes (leftmost and rightmost) as those may be modified by necessity of the interval requested by the user.

(define r (cons->rope '("one" . (("two" . "three") . "four"))))

;; All nodes are shared, including the root of the subrope.
(subrope r 3 11)
  ⇒ #<<rope> left: "two" right: "three" length: 8 depth: 1>

;; Here the leftmost nodes are modified to accomodate the requested
;; start index.
(subrope r 10)
  ⇒ #<<rope> left: "e" right: "four" length: 5 depth: 1>

Example 2.8: Obtaining subropes.