2016-12-07 16:38:26 -05:00
|
|
|
package eval;
|
|
|
|
|
2016-12-15 15:33:48 -05:00
|
|
|
import sexpression.*;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <code>FUNCALL</code> represents the FUNCALL function in Lisp.
|
|
|
|
*/
|
|
|
|
public class FUNCALL extends LispFunction {
|
|
|
|
|
|
|
|
public SExpression call(Cons argList) {
|
|
|
|
// make sure we have received at least one argument
|
|
|
|
if (argList.nullp()) {
|
|
|
|
Cons originalSExpr = new Cons(new Symbol("FUNCALL"), argList);
|
|
|
|
|
2016-12-15 15:33:48 -05:00
|
|
|
throw new RuntimeException("too few arguments given to FUNCALL: " + originalSExpr);
|
2016-12-07 16:38:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SExpression cdr = argList.getCdr();
|
|
|
|
Cons applyArgs = new Cons(argList.getCar(), LIST.makeList(cdr));
|
|
|
|
|
|
|
|
return APPLY.apply(applyArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|