1
0
Fork 0

Doc: typos

This commit is contained in:
Miguel de Benito 2014-02-16 11:29:26 +00:00
parent b39dd3d767
commit 4eeea53e89
1 changed files with 88 additions and 98 deletions

View File

@ -1,13 +1,13 @@
<TeXmacs|1.0.6.10> <TeXmacs|1.99.1>
<style|tmdoc> <style|<tuple|tmdoc|english>>
<\body> <\body>
<tmdoc-title|Fundamental tree modification routines> <tmdoc-title|Fundamental tree modification routines>
From an internal point of view, all modifications to the <TeXmacs> edit From an internal point of view, all modifications to the <TeXmacs> edit
tree are decomposed into atomic modifications of eight different types. In tree are decomposed into atomic modifications of eight different types. In
this section, we describe the <value|scheme> interface to these fundamental this section, we describe the <scheme> interface to these fundamental
modification routines. Even though it is usually more convenient to use modification routines. Even though it is usually more convenient to use
higher level modification routines, as described in the <hlink|next higher level modification routines, as described in the <hlink|next
section|edit-modify.en.tm>, the fundamental tree modification routines may section|edit-modify.en.tm>, the fundamental tree modification routines may
@ -18,166 +18,159 @@
user to verify that the operations are valid and that they lead to a 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 correct new edit tree. Although it is sometimes possible to leave the edit
tree in a temporarily incorrect or ``unsimplified'' state (for instance, by tree in a temporarily incorrect or ``unsimplified'' state (for instance, by
allowing subtrees of the form <group|<scm|(concat "")>>), this practice is allowing subtrees of the form <rigid|<scm|(concat "")>>), this practice is
not generally recommended, and may lead to severe bugs. not generally recommended, and may lead to severe bugs.
<\explain> <\explain>
<explain-scm-macro|tree-assign!|<scm-arg|var>|<scm-arg|new-value>><explain-synopsis|tree <scm|(tree-assign! <scm-arg|var> <scm-arg|new-value>)><explain-synopsis|tree
assignment> assignment>
<|explain> <|explain>
On input, we have a <value|scheme> variable <scm-arg|var> of type On input, we have a <scheme> variable <scm-arg|var> of type
<verbatim|tree> and <scm-arg|new-value> of type <verbatim|content>. The <verbatim|tree> and <scm-arg|new-value> of type <verbatim|content>. The
macro replaces the tree by <scm-arg|new-value> and updates <scm-arg|var> macro replaces the tree by <scm-arg|new-value> and updates <scm-arg|var>
accordingly. The new tree value of <scm-arg|var> is returned. accordingly. The new tree value of <scm-arg|var> is returned.
</explain> </explain>
<\explain> <\explain>
<explain-scm-macro|tree-insert!|<scm-arg|var>|<scm-arg|pos>|<scm-arg|ins>><explain-synopsis|insertion <scm|(tree-insert! <scm-arg|var> <scm-arg|pos>
of new nodes or characters> <scm-arg|ins>)><explain-synopsis|insertion of new nodes or characters>
<|explain> <|explain>
The first parameter <scm-arg|var> is a <value|scheme> variable of type The first parameter <scm-arg|var> is a <scheme> variable of type
<verbatim|tree>. If <scm-arg|var> is a compound tree, then <scm-arg|ins> <verbatim|tree>. If <scm-arg|var> is a compound tree, then <scm-arg|ins>
should be a list <with|mode|math|u<rsub|0>,\<ldots\>,u<rsub|l-1>> of new should be a list <math|u<rsub|0>,\<ldots\>,u<rsub|l-1>> of new children
children of type <verbatim|content>. In that case, the routine inserts of type <verbatim|content>. In that case, the routine inserts
<with|mode|math|u<rsub|0>,\<ldots\>,u<rsub|l-1>> into the children of <math|u<rsub|0>,\<ldots\>,u<rsub|l-1>> into the children of
<scm-arg|var>, at position<nbsp><scm-arg|pos> (see figure <scm-arg|var>, at position <scm-arg|pos> (see figure
<reference|insert-remove-fig>). If <scm-arg|var> is a string tree, then <reference|insert-remove-fig>). If <scm-arg|var> is a string tree, then
<scm-arg|ins> should be of string content type, and the string <scm-arg|ins> should be of string content type, and the string
<scm-arg|ins> is inserted into <scm-arg|var> at <scm-arg|ins> is inserted into <scm-arg|var> at position <scm-arg|pos>.
position<nbsp><scm-arg|pos>. The variable <scm-arg|var> is updated with The variable <scm-arg|var> is updated with the result of the insertion
the result of the insertion and the result is returned. and the result is returned.
</explain> </explain>
<\explain> <\explain>
<explain-scm-macro|tree-remove!|<scm-arg|var>|<scm-arg|pos>|<scm-arg|nr>><explain-synopsis|removal <scm|(tree-remove! <scm-arg|var> <scm-arg|pos>
of nodes or characters> <scm-arg|nr>)><explain-synopsis|removal of nodes or characters>
<|explain> <|explain>
The first parameter <scm-arg|var> is a <value|scheme> variable of type The first parameter <scm-arg|var> is a <scheme> variable of type
<verbatim|tree>. If <scm-arg|var> is a compound tree, then <scm-arg|nr> <verbatim|tree>. If <scm-arg|var> is a compound tree, then <scm-arg|nr>
of its children are removed, starting at position <scm-arg|pos> (see of its children are removed, starting at position <scm-arg|pos> (see
figure <reference|insert-remove-fig>). If <scm-arg|var> is a string tree, figure <reference|insert-remove-fig>). If <scm-arg|var> is a string tree,
then <scm-arg|nr> characters are removed, starting at then <scm-arg|nr> characters are removed, starting at position
position<nbsp><scm-arg|pos>. The variable <scm-arg|var> is updated with <scm-arg|pos>. The variable <scm-arg|var> is updated with the result of
the result of the removal and the result is returned. the removal and the result is returned.
</explain> </explain>
<\big-figure> <\big-figure>
<\equation*> <\equation*>
<tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|insert(t,i,u)>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|i-1>|u<rsub|0>|\<cdots\>|u<rsub|l-1>|t<rsub|i>|\<cdots\>|t<rsub|n-1>>>>>>>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|remove(t,i,l)>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|i-1>|t<rsub|i+l>|\<cdots\>|t<rsub|n-1>>>>>>>>>>>> <tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|insert<around|(|t,i,u|)>>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|i-1>|u<rsub|0>|\<cdots\>|u<rsub|l-1>|t<rsub|i>|\<cdots\>|t<rsub|n-1>>>>>>>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|remove<around|(|t,i,l|)>>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|i-1>|t<rsub|i+l>|\<cdots\>|t<rsub|n-1>>>>>>>>>>>>
</equation*> </equation*>
\; \;
<|big-figure> <|big-figure>
<label|insert-remove-fig>Illustration of the operations <label|insert-remove-fig>Illustration of the operations
<scm|(<scm-macro|tree-insert!> t i u)> and <scm|(<scm-macro|tree-remove!> <scm|(tree-insert! t i u)> and <scm|(tree-remove! t i l)>. If <scm|u> has
t i l)>. If <scm|u> has length<nbsp><scm|l>, then we notice that length<nbsp><scm|l>, then we notice that <scm|(tree-remove! t i l)> undos
<scm|(<scm-macro|tree-remove!> t i l)> undos the insertion the insertion <scm|(tree-insert! t i u)>.
<scm|(<scm-macro|tree-insert!> t i u)>.
</big-figure> </big-figure>
\; \;
<\explain> <\explain>
<explain-scm-macro|tree-split!|<scm-arg|var>|<scm-arg|pos>|<scm-arg|at>><explain-synopsis|split <scm|(tree-split! <scm-arg|var> <scm-arg|pos>
the children into two parts> <scm-arg|at>)><explain-synopsis|split the children into two parts>
<|explain> <|explain>
The first parameter <scm-arg|var> is a <value|scheme> variable of type The first parameter <scm-arg|var> is a <scheme> variable of type
<verbatim|tree>. The macro is used to split the child <with|mode|math|u> <verbatim|tree>. The macro is used to split the child <math|u> of
of <scm-arg|var> at position <scm-arg|pos> into two parts. If <scm-arg|var> at position <scm-arg|pos> into two parts. If <math|u> is a
<with|mode|math|u> is a compound tree, then the first part consists of compound tree, then the first part consists of the first <scm-arg|at>
the first <scm-arg|at> children and the second part of the remaining children and the second part of the remaining ones. Both parts carry the
ones. Both parts carry the same label as <with|mode|math|u> and same label as <math|u> and <math|u> is replaced by the two parts inside
<with|mode|math|u> is replaced by the two parts inside <scm-arg|var> (see <scm-arg|var> (see figure <reference|split-join-fig>). If <math|u> is
figure <reference|split-join-fig>). If <with|mode|math|u> is string tree, string tree, then it is rather split into two strings at position
then it is rather split into two strings at position <scm-arg|at>. The <scm-arg|at>. The variable <scm-arg|var> is updated with the result of
variable <scm-arg|var> is updated with the result of the split command the split command and the result is returned.
and the result is returned.
</explain> </explain>
<\explain> <\explain>
<explain-scm-macro|tree-join!|<scm-arg|var>|<scm-arg|pos>><explain-synopsis|join <scm|(tree-join! <scm-arg|var> <scm-arg|pos>)><explain-synopsis|join two
two adjacent nodes> adjacent nodes>
<|explain> <|explain>
The first parameter <scm-arg|var> is a <value|scheme> variable of type The first parameter <scm-arg|var> is a <scheme> variable of type
<verbatim|tree>. This macro is used to join the child <with|mode|math|u> <verbatim|tree>. This macro is used to join the child <math|u> of
of <scm-arg|var> at position <scm-arg|pos> with the child <scm-arg|var> at position <scm-arg|pos> with the child <math|v> at
<with|mode|math|v> at position <scm-arg|pos>+1. If <with|mode|math|u> and position <scm-arg|pos>+1. If <math|u> and <math|v> are trees, then they
<with|mode|math|v> are trees, then they are removed from <scm-arg|var> are removed from <scm-arg|var> and replaced by a single tree which has
and replaced by a single tree which has the same label as the same label as <math|u> and whose children are those of <math|u>,
<with|mode|math|u> and whose children are those of <with|mode|math|u>, followed by the children of <math|v> (see figure
followed by the children of <with|mode|math|v> (see figure <reference|split-join-fig>). If <math|u> and <math|v> are strings, then
<reference|split-join-fig>). If <with|mode|math|u> and <with|mode|math|v> they are replaced by their concatenation. The variable <scm-arg|var> is
are strings, then they are replaced by their concatenation. The variable updated with the result of the join command and the result is returned.
<scm-arg|var> is updated with the result of the join command and the
result is returned.
</explain> </explain>
<\big-figure> <\big-figure>
<\equation*> <\equation*>
<tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,k-1>>|l+1fn||r-1fn||>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|split(t,i,j)>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>>|l+1fn||||>|<resize|<tree|t<rsub|i>|t<rsub|i,j>|\<cdots\>|t<rsub|i,k-1>>|||r-1fn||>|\<cdots\>|t<rsub|n-1>>>>>>><space|1em><space|1em>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>>|l+2fn||||>|<resize|<tree|t<rsub|i+1>|t<rsub|i+1,j>|\<cdots\>|t<rsub|i+1,k-1>>|||r-2fn||>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|join(t,i)>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>|t<rsub|i+1,0>|\<cdots\>|t<rsub|i+1,k-1>>|l+4fn||r-4fn||>|\<cdots\>|t<rsub|n-1>>>>>>>>>>>> <tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,k-1>>|<plus|1l|1fn>||<minus|1r|1fn>|>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|split<around|(|t,i,j|)>>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>>|<plus|1l|1fn>|||>|<resize|<tree|t<rsub|i>|t<rsub|i,j>|\<cdots\>|t<rsub|i,k-1>>|||<minus|1r|1fn>|>|\<cdots\>|t<rsub|n-1>>>>>>><space|1em><space|1em>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>>|<plus|1l|2fn>|||>|<resize|<tree|t<rsub|i+1>|t<rsub|i+1,j>|\<cdots\>|t<rsub|i+1,k-1>>|||<minus|1r|2fn>|>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|join<around|(|t,i|)>>>|<cell|>|<cell|<tree|t|t<rsub|0>|\<cdots\>|<resize|<tree|t<rsub|i>|t<rsub|i,0>|\<cdots\>|t<rsub|i,j-1>|t<rsub|i+1,0>|\<cdots\>|t<rsub|i+1,k-1>>|<plus|1l|4fn>||<minus|1r|4fn>|>|\<cdots\>|t<rsub|n-1>>>>>>>>>>>>
</equation*> </equation*>
\; \;
<|big-figure> <|big-figure>
<label|split-join-fig>Illustration of the operations <label|split-join-fig>Illustration of the operations <scm|(tree-split! t
<scm|(<scm-macro|tree-split!> t i j)> and <scm|(<scm-macro|tree-join!> t i j)> and <scm|(tree-join! t i)>. Notice that <scm|(tree-join! t i)>
i)>. Notice that <scm|(<scm-macro|tree-join!> t i)> undos undos <scm|(tree-split! t i j)>.
<scm|(<scm-macro|tree-split!> t i j)>.
</big-figure> </big-figure>
<\explain> <\explain>
<explain-scm-macro|tree-assign-node!|<scm-arg|var>|<scm-arg|lab>><explain-synopsis|assign <scm|(tree-assign-node! <scm-arg|var>
the label of a tree> <scm-arg|lab>)><explain-synopsis|assign the label of a tree>
<|explain> <|explain>
This macro replaces the label of a compound tree stored in a This macro replaces the label of a compound tree stored in a <scheme>
<value|scheme> variable <scm-arg|var> by a new value <scm-arg|lab>. The variable <scm-arg|var> by a new value <scm-arg|lab>. The result of the
result of the substitution is returned. substitution is returned.
</explain> </explain>
<\explain> <\explain>
<explain-scm-macro|tree-insert-node!|<scm-arg|var>|<scm-arg|pos>|<scm-arg|ins>><explain-synopsis|insert <scm|(tree-insert-node! <scm-arg|var> <scm-arg|pos>
the tree as a child of another one> <scm-arg|ins>)><explain-synopsis|insert the tree as a child of another
one>
<|explain> <|explain>
Given a <value|scheme> variable <scm-arg|var>, containing a tree, and a Given a <scheme> variable <scm-arg|var>, containing a tree, and a content
content tree <scm-arg|ins>, this macro replaces <scm-arg|var> by tree <scm-arg|ins>, this macro replaces <scm-arg|var> by <scm-arg|ins>,
<scm-arg|ins>, with <scm-arg|var> inserted as a new child of with <scm-arg|var> inserted as a new child of <scm-arg|ins> at position
<scm-arg|ins> at position <scm-arg|pos> (see figure <scm-arg|pos> (see figure <reference|insert-remove-node-fig>). The result
<reference|insert-remove-node-fig>). The result of the insertion is of the insertion is returned.
</explain>
<\explain>
<scm|(tree-remove-node! <scm-arg|var>
<scm-arg|pos>)><explain-synopsis|replace a tree by a child>
<|explain>
Given a <scheme> variable <scm-arg|var>, containing a compound tree, this
macro replaces <scm-arg|var> by its child at position <scm-arg|pos> (see
figure <reference|insert-remove-node-fig>). The value of this child is
returned. returned.
</explain> </explain>
<\explain>
<explain-scm-macro|tree-remove-node!|<scm-arg|var>|<scm-arg|pos>><explain-synopsis|replace
a tree by a child>
<|explain>
Given a <value|scheme> variable <scm-arg|var>, containing a compound
tree, this macro replaces <scm-arg|var> by its child at position
<scm-arg|pos> (see figure <reference|insert-remove-node-fig>). The value
of this child is returned.
</explain>
<\big-figure> <\big-figure>
<\equation*> <\equation*>
<tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<cwith|1|1|1|1|cell-valign|c>|<table|<row|<cell|t>|<cell|>|<cell|\<longrightarrowlim\><rsup|insert-node(t,i,u)>>|<cell|>|<cell|<tree|u|u<rsub|0>|\<cdots\>|u<rsub|i-1>|t|u<rsub|i>|\<cdots\>|u<rsub|n-1>>>>>>>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<cwith|1|1|5|5|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|remove-node(t,i)>>|<cell|>|<cell|t<rsub|i>>>>>>>>>>> <tabular*|<tformat|<table|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<cwith|1|1|1|1|cell-valign|c>|<table|<row|<cell|t>|<cell|>|<cell|\<longrightarrowlim\><rsup|insert-node<around|(|t,i,u|)>>>|<cell|>|<cell|<tree|u|u<rsub|0>|\<cdots\>|u<rsub|i-1>|t|u<rsub|i>|\<cdots\>|u<rsub|n-1>>>>>>>>>|<row|<cell|>>|<row|<cell|<tabular*|<tformat|<cwith|1|1|3|3|cell-valign|c>|<cwith|1|1|5|5|cell-valign|c>|<table|<row|<cell|<tree|t|t<rsub|0>|\<cdots\>|t<rsub|n-1>>>|<cell|>|<cell|\<longrightarrowlim\><rsup|remove-node<around|(|t,i|)>>>|<cell|>|<cell|t<rsub|i>>>>>>>>>>>
</equation*> </equation*>
\; \;
<|big-figure> <|big-figure>
<label|insert-remove-node-fig>Illustration of the operations <label|insert-remove-node-fig>Illustration of the operations
<scm|(<scm-macro|tree-insert-node!> t i u)> and <scm|(tree-insert-node! t i u)> and <scm|(tree-remove-node! t i)>. Notice
<scm|(<scm-macro|tree-remove-node!> t i)>. Notice that the second that the second operation undoes the first one.
operation undos the first one.
</big-figure> </big-figure>
<\remark> <\remark>
Each of the macros <scm-macro|tree-assign!>, <scm-macro|tree-insert!>, Each of the macros <scm|tree-assign!>, <scm|tree-insert!>, <abbr|etc.>
<abbr|etc.> has a functional counterpart has a functional counterpart <verbatim|<scm|tree-assign>>,
<verbatim|<scm-fun|tree-assign>>, <verbatim|<scm-fun|tree-insert>>, etc. <verbatim|<scm|tree-insert>>, etc. The first parameter of these
The first parameter of these counterparts can be an arbitrary counterparts can be an arbitrary ``l-<no-break>value'' and does not have
``l-<no-break>value'' and does not have to be a scheme variable. However, to be a scheme variable. However, in the case when a <scheme> variable is
in the case when a <value|scheme> variable is passed as the first passed as the first parameter, these variants do not necessarily update
parameter, these variants do not necessarily update its contents with the its contents with the return value.
return<nbsp>value.
</remark> </remark>
<tmdoc-copyright|2005|Joris van der Hoeven> <tmdoc-copyright|2005|Joris van der Hoeven>
@ -190,8 +183,5 @@
Documentation License".> Documentation License".>
</body> </body>
<\initial> <initial|<\collection>
<\collection> </collection>>
<associate|language|english>
</collection>
</initial>