Newer
Older
zweic / tests / 5 / antoineyersion / strings(8).zwei
@glproj03 glproj03 on 6 Feb 2006 755 bytes compiler working!
//#isut
class List {
     Int isEmpty() { return this.isEmpty() }
     Int head() { return this.head() }
     List tail() { return this.tail() }
     List cons(Int x) { return this.cons(x) }
     Null println() {}
}

class Cons extends List {
     Int head;
     List tail;
     Int isEmpty() { return false }
     Int head() { return this.head }
     List tail() { return this.tail }
     List cons(Int x) { return new Cons(x, this) }
     Null println() {
	     printChar(this.head);
	     this.tail.println();
     }
}

class Nil extends List {
     Int isEmpty() { return true }
     List cons(Int x) { return new Cons(x, this) }
     Null println() {
	     printChar(10);
	     printChar(13);
     }
} 
{
	List str = "hello, world";
	str.println();
}