<\body> From an internal point of view, all modifications to the edit tree are decomposed into atomic modifications of eight different types. In this section, we describe the interface to these fundamental modification routines. Even though it is usually more convenient to use higher level modification routines, as described in the , the fundamental tree modification routines may occasionally be useful as well. It should be emphasized that the fundamental tree modification routines are checked for their correctness. It is the responsability of the user to verify that the operations are valid and that they lead to a correct new edit tree. Although it is sometimes possible to leave the edit tree in a temporarily incorrect or ``unsimplified'' state (for instance, by allowing subtrees of the form >), this practice is not generally recommended, and may lead to severe bugs. <\explain> |> <|explain> On input, we have a variable of type and of type . The macro replaces the tree by and updates accordingly. The new tree value of is returned. <\explain> ||> <|explain> The first parameter is a variable of type . If is a compound tree, then should be a list ,\,u> of new children of type . In that case, the routine inserts ,\,u> into the children of , at position (see figure ). If is a string tree, then should be of string content type, and the string is inserted into at position. The variable is updated with the result of the insertion and the result is returned. <\explain> ||> <|explain> The first parameter is a variable of type . If is a compound tree, then of its children are removed, starting at position (see figure ). If is a string tree, then characters are removed, starting at position. The variable is updated with the result of the removal and the result is returned. <\big-figure> <\equation*> ||\|t>>||>|||\|t|u|\|u|t|\|t>>>>>>>>|>|||\|t>>||>|||\|t|t|\|t>>>>>>>>>>> \; <|big-figure> Illustration of the operations t i u)> and t i l)>. If has length, then we notice that t i l)> undos the insertion t i u)>. \; <\explain> ||> <|explain> The first parameter is a variable of type . The macro is used to split the child of at position into two parts. If is a compound tree, then the first part consists of the first children and the second part of the remaining ones. Both parts carry the same label as and is replaced by the two parts inside (see figure ). If is string tree, then it is rather split into two strings at position . The variable is updated with the result of the split command and the result is returned. <\explain> |> <|explain> The first parameter is a variable of type . This macro is used to join the child of at position with the child at position +1. If and are trees, then they are removed from and replaced by a single tree which has the same label as and whose children are those of , followed by the children of (see figure ). If and are strings, then they are replaced by their concatenation. The variable is updated with the result of the join command and the result is returned. <\big-figure> <\equation*> ||\||t|\|t>|l+1fn||r-1fn||>|\|t>>||>|||\||t|\|t>|l+1fn||||>||t|\|t>|||r-1fn||>|\|t>>>>>>>>|>|||\||t|\|t>|l+2fn||||>||t|\|t>|||r-2fn||>|\|t>>||>|||\||t|\|t|t|\|t>|l+4fn||r-4fn||>|\|t>>>>>>>>>>> \; <|big-figure> Illustration of the operations t i j)> and t i)>. Notice that t i)> undos t i j)>. <\explain> |> <|explain> This macro replaces the label of a compound tree stored in a variable by a new value . The result of the substitution is returned. <\explain> ||> <|explain> Given a variable , containing a tree, and a content tree , this macro replaces by , with inserted as a new child of at position (see figure ). The result of the insertion is returned. <\explain> |> <|explain> Given a variable , containing a compound tree, this macro replaces by its child at position (see figure ). The value of this child is returned. <\big-figure> <\equation*> ||||>|||\|u|t|u|\|u>>>>>>>>|>||||\|t>>||>||>>>>>>>>>> \; <|big-figure> Illustration of the operations t i u)> and t i)>. Notice that the second operation undos the first one. <\remark> Each of the macros , , has a functional counterpart >, >, etc. The first parameter of these counterparts can be an arbitrary ``l-value'' and does not have to be a scheme variable. However, in the case when a variable is passed as the first parameter, these variants do not necessarily update its contents with the returnvalue. <\initial> <\collection>