public class GetNth implements IFunAlgo { private static GetNth _instance = new GetNth (); private GetNth () { } public static GetNth Singleton () { return _instance; } public Object forEmpty (EmptyFW list, Object input) { throw new java.util.NoSuchElementException ("Empty has no data."); } public Object forCons (ConsFW list, Object input) { int n = ((Integer)input).intValue (); if (0 == n) { return list.car (); } else { return list.cdr ().execute (this, new Integer (--n)); } } }