package jetbrains.mps.samples.lambdaCalculus.runtime;

/*Generated by MPS */

import java.util.List;
import java.util.ArrayList;

public abstract class Function {
  protected List myArgs = new ArrayList();
  protected String myType;
  public Function() {
  }
  public Object apply(Object... argValue) {
    for (Object arg : argValue) {
      this.myArgs.add(arg);
    }
    if (this.myArgs.size() == this.getParamsCount()) {
      return this.eval();
    } else {
      return this;
    }
  }
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("Function(");
    int j = 0;
    for (Object arg : this.myArgs) {
      sb.append(arg);
      if (j != this.getParamsCount() - 1) {
        sb.append(", ");
      }
      j++;
    }
    for (int i = this.myArgs.size(); i < this.getParamsCount(); i++) {
      sb.append("__");
      if (i != this.getParamsCount() - 1) {
        sb.append(", ");
      }
    }
    sb.append(") : ");
    sb.append(this.myType);
    return sb.toString();
  }
  public abstract Object eval();
  public abstract Function copy();
  public abstract int getParamsCount();
}
