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
|
|
|
|
2017-02-24 16:00:05 -05:00
|
|
|
public class FIRST extends LispFunction {
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2016-12-23 10:53:11 -05:00
|
|
|
private ArgumentValidator argumentValidator;
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-02-24 16:00:05 -05:00
|
|
|
public FIRST() {
|
|
|
|
this.argumentValidator = new ArgumentValidator("FIRST");
|
2016-12-23 10:53:11 -05:00
|
|
|
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);
|
2017-02-24 11:07:06 -05:00
|
|
|
Cons argument = (Cons) argumentList.getFirst();
|
2016-12-07 16:38:26 -05:00
|
|
|
|
2017-02-24 11:07:06 -05:00
|
|
|
return argument.getFirst();
|
2016-12-07 16:38:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|