class List { def isEmpty(): Int = this.isEmpty(); def head() : Int = this.head(); def tail() : List = this.tail(); def cons(x: Int): List = new Cons(x,this); def print() { if(this.isEmpty()) printChar(10); else { printInt(this.head()); do this.tail().print(); } } } class Cons extends List { val head : Int; val tail : List; def isEmpty(): Int = false; def head() : Int = this.head; def tail() : List = this.tail; } class Nil extends List { def isEmpty(): Int = true; } { var l : List = new Nil(); set l = l.cons(1); set l = l.cons(2); do l.print(); }