Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save filipevarjao/b213201ac7aecda391317860181f0c82 to your computer and use it in GitHub Desktop.
Save filipevarjao/b213201ac7aecda391317860181f0c82 to your computer and use it in GitHub Desktop.
class List extends Object {
List() { super(); }
List append(List l) {
return this; // dummy
}
}
class Nil extends List {
Nil() { super (); }
List append(List l) {
return l;
}
}
class Elem extends List {
Object a; List next;
Elem(Object a, List next) {
super();
this.a = a;
this.next = next;
}
List append(List l) {
return new Elem(this.a, this.next.append(l));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment