2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.cons;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2016-12-23 10:53:11 -05:00
|
|
|
import function.*;
|
2016-12-15 15:33:48 -05:00
|
|
|
import sexpression.*;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
|
|
|
public class CAR extends LispFunction {
|
|
|
|
|
2016-12-23 10:53:11 -05:00
|
|
|
private ArgumentValidator argumentValidator;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2016-12-23 10:53:11 -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
|
|
|
|
2016-12-23 10:53:11 -05:00
|
|
|
public SExpression call(Cons argumentList) {
|
|
|
|
argumentValidator.validate(argumentList);
|
|
|
|
Cons argument = (Cons) argumentList.getCar();
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2016-12-23 10:53:11 -05:00
|
|
|
return argument.getCar();
|
2016-12-07 16:38:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|