mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-22 23:40:08 -08:00
Make pow an operator, represented by caret.
This commit is contained in:
parent
65a6265cf6
commit
bc23b8dbda
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user