struct List {};
struct Cons : public List {
Cons(int v, List* nxt);
int v; List* nxt;
};
struct Nil : public List {};
This is how you'd do it in Java.
This is how you'd do it in Java.
Cons(1, Cons(2, Cons(3, Nil)))Here is a definition for a Maybe type, converting it to a List is left as an exercise to the reader :) : https://news.ycombinator.com/item?id=35133670