| OLD | NEW |
| (Empty) |
| 1 part of petitparser.lisp; | |
| 2 | |
| 3 /// The basic data structure of LISP. | |
| 4 class Cons { | |
| 5 | |
| 6 /// The head of the cons. | |
| 7 dynamic head; | |
| 8 | |
| 9 /// The tail of the cons. | |
| 10 dynamic tail; | |
| 11 | |
| 12 /// Constructs a cons. | |
| 13 Cons(this.head, this.tail); | |
| 14 | |
| 15 @override | |
| 16 bool operator ==(other) { | |
| 17 return other is Cons && head == other.head && tail == other.tail; | |
| 18 } | |
| 19 | |
| 20 @override | |
| 21 int get hashCode => 31 * head.hashCode + tail.hashCode; | |
| 22 | |
| 23 @override | |
| 24 String toString() { | |
| 25 var buffer = new StringBuffer(); | |
| 26 buffer.write('('); | |
| 27 var current = this; | |
| 28 while (current is Cons) { | |
| 29 buffer.write(current.head.toString()); | |
| 30 current = current.tail; | |
| 31 if (current != null) { | |
| 32 buffer.write(' '); | |
| 33 } | |
| 34 } | |
| 35 if (current != null) { | |
| 36 buffer.write('. '); | |
| 37 buffer.write(current); | |
| 38 } | |
| 39 buffer.write(')'); | |
| 40 return buffer.toString(); | |
| 41 } | |
| 42 } | |
| OLD | NEW |