Skip to content

Commit

Permalink
Add modulo operation
Browse files Browse the repository at this point in the history
  • Loading branch information
p-e-w committed Mar 7, 2015
1 parent 42c21ae commit ea77ef3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "Sequencer"

version := "1.4.0"
version := "1.5.0"

organization := "com.worldwidemann"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class ExpressionLibrary(configuration: Configuration) {
private val SUBTRACT = BinaryInfixOperator("-", (x, y) => x - y)
private val MULTIPLY = BinaryInfixOperator("*", (x, y) => x * y)
private val DIVIDE = BinaryInfixOperator("/", (x, y) => x / y)
private val MODULO = BinaryPrefixOperator("Mod", (x, y) => x % y)
private val POWER = BinaryInfixOperator("^", (x, y) => math.pow(x, y))
private val MAX = BinaryPrefixOperator("Max", (x, y) => math.max(x, y))
private val MIN = BinaryPrefixOperator("Min", (x, y) => math.min(x, y))
private val standardFunctions = Array[Expression](NEGATE, SQRT, ABS, SIGN, FLOOR, CEILING, ROUND, ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER, MAX, MIN)
private val standardFunctions = Array[Expression](NEGATE, SQRT, ABS, SIGN, FLOOR, CEILING, ROUND,
ADD, SUBTRACT, MULTIPLY, DIVIDE, MODULO, POWER, MAX, MIN)

private val previousElements = (1 to configuration.recurrenceDepth).map(PreviousElement(_)).toArray[Expression]

Expand Down Expand Up @@ -130,6 +132,8 @@ class ExpressionLibrary(configuration: Configuration) {
ROUND -> integerExpressions,
// 1*x = x*1 = x
MULTIPLY -> Array[Expression](ONE),
// 1%x = 1, x%1 = 0
MODULO -> (Array[Expression](ONE) ++ nonIntegerExpressions),
// 1^x = 1, x^1 = x
POWER -> Array[Expression](ONE),
FACTORIAL -> (integers ++ nonIntegerExpressions),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scopt.OptionParser

object SequencerRunner {
def main(args: Array[String]) {
println("Sequencer 1.4.0 (https://github.com/p-e-w/sequencer)\n")
println("Sequencer 1.5.0 (https://github.com/p-e-w/sequencer)\n")

// Suppress annoying Symja console output (idea from http://stackoverflow.com/a/8363580).
// This is a very brittle solution. In particular, if we do not use the Console stream
Expand Down

0 comments on commit ea77ef3

Please sign in to comment.