From 8fb82e1fb8f8d2a57e9891d54d2c5a169459831b Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Thu, 27 Jul 2017 13:47:51 -0700 Subject: [PATCH] Add sqrt function. --- src/org/nwapw/abacus/plugin/StandardPlugin.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/org/nwapw/abacus/plugin/StandardPlugin.java b/src/org/nwapw/abacus/plugin/StandardPlugin.java index 76d7826..8058e49 100755 --- a/src/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/org/nwapw/abacus/plugin/StandardPlugin.java @@ -220,6 +220,18 @@ public class StandardPlugin extends Plugin { 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) { + return params.length == 1; + } + + @Override + protected NumberInterface applyInternal(NumberInterface[] params) { + return StandardPlugin.this.getFunction("pow").apply(params[0], (new NaiveNumber(0.5))); + } + }); } /**