25 lines
630 B
Java
25 lines
630 B
Java
package function.builtin.cons;
|
|
|
|
import function.*;
|
|
import sexpression.*;
|
|
|
|
@FunctionNames({ "FIRST", "CAR" })
|
|
public class FIRST extends LispFunction {
|
|
|
|
private ArgumentValidator argumentValidator;
|
|
|
|
public FIRST() {
|
|
this.argumentValidator = new ArgumentValidator("FIRST");
|
|
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();
|
|
}
|
|
|
|
}
|