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


2.6 Concatenation

Procedure: rope-append rope …

Appends the rope together with all the rest of the arguments.

(rope-append rope …) ≡ (rope-concatenate (list rope …))

See rope-concatenate for details.

Procedure: rope-concatenate ropes

Concatenates the members of the ropes list into a single rope, and balances it if necessary with rope-balance. The behavior of this function is different from folding with the rope constructor, because it applies optimizations in the case where one of the argument s is a string: if the other argument is also a string, or the son or grandson of the root is a string, then the strings may be appended together as long as *rope-maximum-leaf-size* is respected.

;; Case 1) two strings.
(rope-concatenate (list "one" "two"))
  ⇒ "onetwo"

;; Case 2) son of root optimization.
(rope-concatenate (list "one" (rope "two" …)))
  ⇒ #<<rope> left: "onetwo" right: … >

;; Case 3) grandson of root optimization
(rope-concatenate (list "one" (rope (rope "two" …) …)))
  ⇒ #<<rope> left: #<<rope> left: "onetwo" right: …> right: …>

;; Case 4) generic concatenation of ropes.
(rope-concatenate (list r1 r2)) ≡ (rope r1 r2)

Example 2.7: The four different cases that may occur in rope concatenation.