LENGTH no longer creates a new instance

This commit is contained in:
Mike Cifelli 2017-11-19 11:17:32 -05:00
parent 1301e0a227
commit a8d8d6696c
1 changed files with 6 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package function.builtin.cons;
import static function.builtin.cons.LIST.makeList;
import static recursion.TailCalls.done;
import static recursion.TailCalls.tailCall;
import static table.FunctionTable.lookupFunction;
import java.math.BigInteger;
@ -17,12 +18,15 @@ import sexpression.LispNumber;
public class LENGTH extends LispFunction {
public static BigInteger getLength(Cons list) {
LENGTH lengthFunction = new LENGTH("LENGTH");
LispNumber length = lengthFunction.callWithoutArgumentValidation(makeList(list));
LispNumber length = lookupLength().callWithoutArgumentValidation(makeList(list));
return length.getValue();
}
private static LENGTH lookupLength() {
return (LENGTH) lookupFunction("LENGTH");
}
private ArgumentValidator argumentValidator;
public LENGTH(String name) {