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


2.12.4 Mutation

Procedure: rope-transpose-contract rope-transpose

Contract the path denoted by rope-transpose once, shortening it by one. The parent becomes the current node, and so on.

This procedure is useful if one wishes to propagate a new value for a node into a rope: first manipulate the current node of rope-transpose, and then use this procedure repeatedly to construct a new rope with the new value in place. See also rope-transpose-contract*.

Procedure: rope-transpose-contract* rope-transpose

Contract the path denoted by rope-transpose repeatedly according to rope-transpose-contract until the current node becomes a newly reconstructed rope.

For example, let’s replace the ‘o’ letter in the rope below with ‘O’:

(define r (cons->rope '(("w" . "o") "w" . "!")))
(define path (rope-transpose-from-index r 1))
;; Replace "o" by "O":
(define new-path (set-rope-transpose-node path "O"))
(rope->cons
  (rope-transpose-node
    (rope-transpose-contract* new-path)))
  ⇒ (("w" . "O") "w" . "!")