Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Added mod operator (%)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennygrant authored and alfredxing committed Feb 17, 2015
1 parent 13f61c4 commit a1b6f1d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions operators/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -59,6 +68,7 @@ var (
return math.Pow(args[0], args[1])
},
}

)

func init() {
Expand All @@ -67,5 +77,6 @@ func init() {
Register(neg)
Register(pow)
Register(mul)
Register(mod)
Register(div)
}

0 comments on commit a1b6f1d

Please sign in to comment.