transcendental-lisp/src/function/builtin/cons/FIRST.java

24 lines
595 B
Java
Raw Normal View History

package function.builtin.cons;
2016-12-07 16:38:26 -05:00
import function.*;
import sexpression.*;
2016-12-07 16:38:26 -05:00
public class FIRST extends LispFunction {
2016-12-07 16:38:26 -05:00
private ArgumentValidator argumentValidator;
2016-12-07 16:38:26 -05:00
public FIRST() {
this.argumentValidator = new ArgumentValidator("FIRST");
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.getFirst();
2016-12-07 16:38:26 -05:00
return argument.getFirst();
2016-12-07 16:38:26 -05:00
}
}