package function.builtin.cons;

import function.*;
import sexpression.*;

@FunctionNames({ "FIRST", "CAR" })
public class FIRST extends LispFunction {

    private ArgumentValidator argumentValidator;

    public FIRST(String name) {
        this.argumentValidator = new ArgumentValidator(name);
        this.argumentValidator.setExactNumberOfArguments(1);
        this.argumentValidator.setEveryArgumentExpectedType(Cons.class);
    }

    @Override
    public SExpression call(Cons argumentList) {
        argumentValidator.validate(argumentList);
        Cons argument = (Cons) argumentList.getFirst();

        return argument.getFirst();
    }

}
