From bc23b8dbda32fc695c669627fa09105eabea063d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 27 Jul 2017 16:55:18 -0700 Subject: [PATCH] Make pow an operator, represented by caret. --- .../nwapw/abacus/plugin/StandardPlugin.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/org/nwapw/abacus/plugin/StandardPlugin.java b/src/org/nwapw/abacus/plugin/StandardPlugin.java index e93f546..8ac8a07 100755 --- a/src/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/org/nwapw/abacus/plugin/StandardPlugin.java @@ -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, ArrayList> storedList = new HashMap, ArrayList>(); @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) {