本文整理汇总了C#中Tree.Node.setForm方法的典型用法代码示例。如果您正苦于以下问题:C# Node.setForm方法的具体用法?C# Node.setForm怎么用?C# Node.setForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree.Node
的用法示例。
在下文中一共展示了Node.setForm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: print
public override void print(Node t, int n, bool p)
{
// Indent (if necessary)
for (int i = 0; i < n; i++) {
Console.Write(" ");
}
// Get the car and cdr
Node car = t.getCar(),
cdr = t.getCdr();
Console.Write("("); // (
car.print(n, true); // Condition
Console.WriteLine(); // Carriage return
n++; // Increase indentation for the
// subsequent arguments
// Set form to regular so it can all print on the same line
// Use false parameter to tell the regular form to not print the
// carriage return
t.setForm(new Regular(false));
while (!cdr.isNil()) { // Print cond's conditions and expressions
for (int i = 0; i < n; i++) { // Indent the parameters of cond
Console.Write(" ");
}
cdr.getCar().print(0, false); // Implicitly recur on cars
Console.WriteLine(); // Carriage return
cdr = cdr.getCdr(); // Recur down the right side of the tree
}
// Decrease indentation because only the arguments needed to
// be indented
n--;
// Indent (if necessary), print the final right parenthesis and the
// final carriage return
for (int i = 0; i < n; i++) {
Console.Write(" ");
}
// Print final right paren and carriage return
cdr.print(0, true);
Console.WriteLine();
}
示例2: print
public override void print(Node t, int n, bool p)
{
// Indent (if necessary)
for (int i = 0; i < n; i++) {
Console.Write(" ");
}
// Get the car and cdr
Node car = t.getCar(),
cdr = t.getCdr();
Console.Write("("); // (
car.print(n, true); // Begin
Console.WriteLine(); // Carriage return
n++; // Increase indentation
// Set form to regular so it can all print on the same line
// Use false parameter to tell the regular form to not print the
// carriage return
t.setForm(new Regular(false));
while (!cdr.isNil()) {
// Indent the parameters of begin if necessary
for (int i = 0; i < n; i++) {
Console.Write(" ");
}
// Print the cadr
// (This implicitly recurs on the left of the tree)
cdr.getCar().print(0, false);
Console.WriteLine();
// Recur on the right of the tree.
cdr = cdr.getCdr();
}
// Print the final right parenthesis with no indentation
// and carriage return
cdr.print(0, true);
Console.WriteLine();
}
示例3: print
public override void print(Node t, int n, bool p)
{
// Indent (if necessary)
for (int i = 0; i < n; i++)
Console.Write(" ");
// Get the car and cdr
Node car = t.getCar(),
cdr = t.getCdr();
// Print "(begin "
Console.Write("(");
car.print(n, true);
Console.WriteLine();
n++;
// Set form to regular so it can all print on the same line
// Use false parameter to tell the regular form to not print the
// carriage return
t.setForm(new Regular(false));
while (!cdr.isNil()) {
// Indent and print all parameters (cadrs) recursively
for (int i = 0; i < n; i++)
Console.Write(" ");
cdr.getCar().print(0, false);
Console.WriteLine();
cdr = cdr.getCdr();
}
// Print the final right parenthesis and carriage return
cdr.print(0, true);
Console.WriteLine();
}