package lrs.lazyLRSEvaluators;

import fp.*;
import lrs.*;

/**
 * Lazily creates a possibly infinite list that squares the Integers in
 * an input list.
 */
public class LazySquareEval extends LazyLambdaApplyEval {
    // FOR STUDENT TO COMPLETE: add fields and methods here
    public LazySquareEval(LRStruct src) {
        super(new ALazyEval() {
            final ILambda squareLambda = new ILambda() {
                public Object apply(Object... p) {
                    LRStruct l = (LRStruct)p[0];
                    Integer i = (Integer)l.removeFront();
                    return i;
                }
            };
            public LRStruct makeLRS() {
                return makeLazyLRS(squareLambda);
            }
            public LRStruct nextLRS() {
                return makeLRS();
            }
        }.makeLRS(),src);
    }
}

