From a1b6f1d61ccd6c2007764d0bf7f999a3897e7074 Mon Sep 17 00:00:00 2001 From: Kenny Grant Date: Mon, 16 Feb 2015 23:02:06 +0000 Subject: [PATCH] Added mod operator (%) --- operators/standard.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/operators/standard.go b/operators/standard.go index f126dbb..1c8c1cf 100644 --- a/operators/standard.go +++ b/operators/standard.go @@ -50,6 +50,15 @@ var ( return args[0] / args[1] }, } + mod = &Operator{ + Name: "%", + Precedence: 2, + Associativity: L, + Args: 2, + Operation: func(args []float64) float64 { + return math.Mod(args[0], args[1]) + }, + } pow = &Operator{ Name: "^", Precedence: 3, @@ -59,6 +68,7 @@ var ( return math.Pow(args[0], args[1]) }, } + ) func init() { @@ -67,5 +77,6 @@ func init() { Register(neg) Register(pow) Register(mul) + Register(mod) Register(div) }