Name: Anonymous 2007-09-25 12:23 ID:to4XxOKg
I want a Java
cdr.
cdr.
public int length(Object o) {
Cons list = (Cons) o;
if (list == null) {
return 0;
} else {
return 1 + length(list.cdr());
}
}
Cons l = new Cons(1, new Cons(2, new Cons(3, new Cons(4, null))));
System.out.println("length is: " + length(l));