Make pow an operator, represented by caret.

This commit is contained in:
Danila Fedorin 2017-07-27 16:55:18 -07:00
parent 65772c8d57
commit f119f19c04
1 changed files with 12 additions and 12 deletions

View File

@ -79,6 +79,18 @@ public class StandardPlugin extends Plugin {
}
}));
registerOperator("^", new Operator(OperatorAssociativity.RIGHT, 2, new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 2;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return StandardPlugin.this.getFunction("exp").apply(StandardPlugin.this.getFunction("ln").apply(params[0]).multiply(params[1]));
}
}));
registerFunction("!", new Function() {
//private HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> storedList = new HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>>();
@Override
@ -211,18 +223,6 @@ public class StandardPlugin extends Plugin {
}
});
registerFunction("pow", new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 2;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return StandardPlugin.this.getFunction("exp").apply(StandardPlugin.this.getFunction("ln").apply(params[0]).multiply(params[1]));
}
});
registerFunction("sqrt", new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {