30 lines
825 B
Java
30 lines
825 B
Java
package function.builtin;
|
|
|
|
import function.ArgumentValidator;
|
|
import function.FunctionNames;
|
|
import function.LispFunction;
|
|
import sexpression.Cons;
|
|
import sexpression.SExpression;
|
|
|
|
import static function.builtin.APPLY.apply;
|
|
import static function.builtin.cons.LIST.makeList;
|
|
|
|
@FunctionNames({ "FUNCALL", "CALL" })
|
|
public class FUNCALL extends LispFunction {
|
|
|
|
private ArgumentValidator argumentValidator;
|
|
|
|
public FUNCALL(String name) {
|
|
this.argumentValidator = new ArgumentValidator(name);
|
|
this.argumentValidator.setMinimumNumberOfArguments(1);
|
|
}
|
|
|
|
@Override
|
|
public SExpression call(Cons argumentList) {
|
|
argumentValidator.validate(argumentList);
|
|
Cons applyArgs = new Cons(argumentList.getFirst(), makeList(argumentList.getRest()));
|
|
|
|
return apply(applyArgs);
|
|
}
|
|
}
|