Begin working on memoization for factorial. (Commented out for now.)

This commit is contained in:
Arthur Drobot 2017-07-27 13:39:19 -07:00
parent 9666ef9019
commit 557bc66e53
1 changed files with 8 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import org.nwapw.abacus.number.NaiveNumber;
import org.nwapw.abacus.number.NumberInterface;
import javax.print.attribute.standard.MediaSize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.function.BiFunction;
/**
@ -76,7 +78,7 @@ public class StandardPlugin extends Plugin {
});
registerFunction("!", new Function() {
//private ArrayLi
//private HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> storedList = new HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>>();
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 1;
@ -94,6 +96,11 @@ public class StandardPlugin extends Plugin {
factorial = factorial.multiply(multiplier);
}
return factorial;
/*if(!storedList.containsKey(params[0].getClass())){
storedList.put(params[0].getClass(), new ArrayList<NumberInterface>());
storedList.get(params[0].getClass()).add(NaiveNumber.ONE.promoteTo(params[0].getClass()));
storedList.get(params[0].getClass()).add(NaiveNumber.ONE.promoteTo(params[0].getClass()));
}*/
}
});