24 lines
589 B
Java
24 lines
589 B
Java
package function.builtin.cons;
|
|
|
|
import function.*;
|
|
import sexpression.*;
|
|
|
|
public class CAR extends LispFunction {
|
|
|
|
private ArgumentValidator argumentValidator;
|
|
|
|
public CAR() {
|
|
this.argumentValidator = new ArgumentValidator("CAR");
|
|
this.argumentValidator.setExactNumberOfArguments(1);
|
|
this.argumentValidator.setEveryArgumentExpectedType(Cons.class);
|
|
}
|
|
|
|
public SExpression call(Cons argumentList) {
|
|
argumentValidator.validate(argumentList);
|
|
Cons argument = (Cons) argumentList.getFirst();
|
|
|
|
return argument.getFirst();
|
|
}
|
|
|
|
}
|