Ropes: join #
Rope.join l r concatenates two ropes. When one side is more than one level taller, it descends
the facing spine of the taller rope until the heights differ by at most one, makes a node there,
and rebuilds the spine with Rope.balanceNode on the way back up. This is the AVL join of
Blelloch, Ferizovic and Sun, Figure 2, without the middle key.
The descents are the helpers Rope.joinRight and Rope.joinLeft, which are public only because
the exposed join calls them.
Join never merges, splits or copies a leaf, so the leaf chunks of the result are those of l
followed by those of r.
For well-formed inputs the result is well-formed and its height is between
max l.height r.height and one more. When one side is empty, the result is the other side.
Rope α has an Append instance given by join, so l ++ r is join l r.
Main definitions #
Rope.join: concatenation of two ropes.
Main results #
Rope.toList_join,Rope.chunks_join: join represents the concatenation and keeps the leaf chunks, with no hypotheses.Rope.isWF_join,Rope.length_join,Rope.height_join: well-formedness, length and the height effect of join.
References #
Join when l is the taller side: descend the right spine of l while l is more than one
level taller than r, then rebuild with balanceNode.