예제 #1
0
 void print(Node t, int n, boolean p) {
   if (p) {
     t.print(n, true);
   } else {
     if (n > 0) {
       for (int i = 0; i < n; i++) System.out.print(" ");
     }
     System.out.print("(");
     if (t.isPair() && t.getCdr() != null) {
       t.getCar().print(n, true);
       t.getCdr().print(-n, true);
     } else if (!t.isPair()) t.print(-n, true);
     else System.err.println("Null Pointer");
   }
 }
예제 #2
0
 void print(Node t, int n, boolean p) {
   if (p == false) {
     System.out.print("(");
   }
   System.out.print("let");
   // print inside stuff indented
   Node c = t.getCdr();
   if (c.isNull()) {
     c.print(0, true);
   } else if (c.isPair()) {
     c.print((n - (n % 4)) + 4, true);
   } else {
     System.out.print('.');
     c.print(0, false);
     System.out.print(')');
   }
 }