
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
Java | size: 0.61 KB | hits: 18 | expires: Never
public class NonEmptyList implements LispList {
private Object hd;
private LispList tl;
public NonEmptyList(Object h, EmptyList l)
{
hd = h;
tl = l;
}
public NonEmptyList(Object h, NonEmptyList l)
{
hd = h;
tl = l;
}
public LispList cons(Object h) {
return new NonEmptyList(h, this);
}
public boolean isEmpty() {
return false;
}
public Object head() {
throw new UnsupportedOperationException();
}
public LispList tail() {
throw new UnsupportedOperationException();
}
public String toString() {
return "";
}
}