Created
April 28, 2016 13:37
-
-
Save filipevarjao/b213201ac7aecda391317860181f0c82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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