diff --git a/src/function/builtin/cons/LENGTH.java b/src/function/builtin/cons/LENGTH.java index ca1270e..2acade0 100644 --- a/src/function/builtin/cons/LENGTH.java +++ b/src/function/builtin/cons/LENGTH.java @@ -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) {