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

24 lines
580 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
import function.*;
import sexpression.*;
2016-12-07 16:38:26 -05:00
public class CAR extends LispFunction {
private ArgumentValidator argumentValidator;
2016-12-07 16:38:26 -05:00
public CAR() {
this.argumentValidator = new ArgumentValidator("CAR");
this.argumentValidator.setExactNumberOfArguments(1);
this.argumentValidator.setEveryArgumentExpectedType(Cons.class);
}
2016-12-07 16:38:26 -05:00
public SExpression call(Cons argumentList) {
argumentValidator.validate(argumentList);
Cons argument = (Cons) argumentList.getCar();
2016-12-07 16:38:26 -05:00
return argument.getCar();
2016-12-07 16:38:26 -05:00
}
}