transcendental-lisp/src/eval/FUNCALL.java

25 lines
640 B
Java
Raw Normal View History

2016-12-07 16:38:26 -05:00
package eval;
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);
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);
}
}