transcendental-lisp/src/function/builtin/FUNCALL.java

26 lines
682 B
Java
Raw Normal View History

2016-12-19 13:05:53 -05:00
package function.builtin;
2016-12-07 16:38:26 -05:00
2016-12-19 13:05:53 -05:00
import function.LispFunction;
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);
}
}