package function.builtin.predicate;

import static sexpression.Nil.NIL;
import static sexpression.Symbol.T;

import function.ArgumentValidator;
import function.FunctionNames;
import function.LispFunction;
import sexpression.Cons;
import sexpression.SExpression;

@FunctionNames({ "NULL", "NULL?" })
public class NULL extends LispFunction {

    private ArgumentValidator argumentValidator;

    public NULL(String name) {
        this.argumentValidator = new ArgumentValidator(name);
        this.argumentValidator.setExactNumberOfArguments(1);
    }

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

        return argumentList.getFirst().isNull() ? T : NIL;
    }

}
