
public class LL<A> {
	A hd;
	Closure<LL<A>> tl;
	boolean isEmpty;
	public LL() {
		isEmpty=true;
	}
	public LL(A hd, Closure<LL<A>> tl) {
		super();
		this.hd = hd;
		this.tl = tl;
		isEmpty=false;
	}
	static Closure<LL<Integer>> from(final int x){
		return new Caf<LL<Integer>>(){
			@Override
			public LL<Integer> calc() {
				return new LL<Integer>(x,from(x+1));
			}
		};
	}
	static <A> Closure<LL<A>> 
	  take(final Closure<LL<A>> xs, final int i){
		if (i==0||xs.get().isEmpty){
			return new Caf<LL<A>>(){
				@Override
				public LL<A> calc() {
					return new LL<A>();
				}
			};
		}
		return  g(xs, i);
	}
	private static <A> Caf<LL<A>> g(final Closure<LL<A>> xs, final int i) {
		return new Caf<LL<A>>(){
				@Override
				public LL<A> calc() {
					return new LL<A>(xs.get().hd
							,take(xs.get().tl,i-1));
				}
			};
	}
	
	static Closure<LL<Integer>> nat = from(1);
	static void print(Closure<LL<Integer>> xs){
		while (!xs.get().isEmpty){
			System.out.println(xs.get().hd+" ");			
			xs=xs.get().tl;
		}
	}
	public static void main(String[] args) {
		print(take(nat,10));
	}
	
}
