package calculator.interpreter.ast.lambda; import java.util.ArrayList; import java.util.LinkedList; import calculator.interpreter.Environment; import calculator.interpreter.Function; import calculator.interpreter.ast.Expression; /** * Apply operation */ public class Apply extends Expression { /** the function */ public Expression function; /** the function arguments */ public final LinkedList<Expression> arguments = new LinkedList<Expression>(); @Override public Object eval(Environment env) { Object f = function.eval(env); ArrayList<Object> args = new ArrayList<Object>(arguments.size()); for (Expression a : arguments) { args.add(a.eval(env)); } return Function.apply(location, f, args); } }