public class GetNth implements FLVisitor_I { private final int index; public GetNth(int i) { index = i; } public Object forEmpty (Empty list) { throw new java.util.NoSuchElementException ("Empty has no data."); } public Object forCons(Cons list) { if (0 == index) { return list.first(); } else return list.rest().execute(new GetNth(index-1)); } }