LENGTH no longer creates a new instance
This commit is contained in:
parent
1301e0a227
commit
a8d8d6696c
|
@ -3,6 +3,7 @@ package function.builtin.cons;
|
||||||
import static function.builtin.cons.LIST.makeList;
|
import static function.builtin.cons.LIST.makeList;
|
||||||
import static recursion.TailCalls.done;
|
import static recursion.TailCalls.done;
|
||||||
import static recursion.TailCalls.tailCall;
|
import static recursion.TailCalls.tailCall;
|
||||||
|
import static table.FunctionTable.lookupFunction;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
@ -17,12 +18,15 @@ import sexpression.LispNumber;
|
||||||
public class LENGTH extends LispFunction {
|
public class LENGTH extends LispFunction {
|
||||||
|
|
||||||
public static BigInteger getLength(Cons list) {
|
public static BigInteger getLength(Cons list) {
|
||||||
LENGTH lengthFunction = new LENGTH("LENGTH");
|
LispNumber length = lookupLength().callWithoutArgumentValidation(makeList(list));
|
||||||
LispNumber length = lengthFunction.callWithoutArgumentValidation(makeList(list));
|
|
||||||
|
|
||||||
return length.getValue();
|
return length.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static LENGTH lookupLength() {
|
||||||
|
return (LENGTH) lookupFunction("LENGTH");
|
||||||
|
}
|
||||||
|
|
||||||
private ArgumentValidator argumentValidator;
|
private ArgumentValidator argumentValidator;
|
||||||
|
|
||||||
public LENGTH(String name) {
|
public LENGTH(String name) {
|
||||||
|
|
Loading…
Reference in New Issue