stepthom / math-fun

Just testing out some fun with mathematics.
2 stars 2 forks source link

Sort terms based on the exponent #3

Closed stepthom closed 11 years ago

stepthom commented 11 years ago

Normally in mathematics, a function is written in descending order of the exponents:

f(x) = x^5 + x^4 + x^3  + ...

However, the way that MathFunctions are randomly generated, the ordering of terms is most likely to be unsorted.

Change the addTerm function in MathFuncion to add the term in the right location, thereby ensuring that a function is always in the right order.

Also, create a unit test or two to ensure that addTerm behaves as expected.

ajslater commented 11 years ago

PR #8 handles this.