mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 16:00:09 -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() {
|
registerFunction("!", new Function() {
|
||||||
//private HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> storedList = new HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>>();
|
//private HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>> storedList = new HashMap<Class<? extends NumberInterface>, ArrayList<NumberInterface>>();
|
||||||
@Override
|
@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() {
|
registerFunction("sqrt", new Function() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesParams(NumberInterface[] params) {
|
protected boolean matchesParams(NumberInterface[] params) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user