Content deleted Content added
Undid revision 941753297 by 90.230.194.205 (talk): ? I don't see anything C++ specific in the code example. |
m linking |
||
Line 11:
A forest ''f'' consists of a list of trees, while a tree ''t'' consists of a pair of a value ''v'' and a forest ''f'' (its children). This definition is elegant and easy to work with abstractly (such as when proving theorems about properties of trees), as it expresses a tree in simple terms: a list of one type, and a pair of two types. Further, it matches many algorithms on trees, which consist of doing one thing with the value, and another thing with the children.
This mutually recursive definition can be converted to a singly recursive definition by [[Inline expansion|inlining]] the definition of a forest:
t: v <nowiki>[t[1], ..., t[k]]</nowiki>
A tree ''t'' consists of a pair of a value ''v'' and a list of trees (its children). This definition is more compact, but somewhat messier: a tree consists of a pair of one type and a list of another, which require disentangling to prove results about.
|