I need to write + operator for polynomials. How can I do that for
(that's an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
···
--
Posted via http://www.ruby-forum.com/.
I need to write + operator for polynomials. How can I do that for
(that's an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
--
Posted via http://www.ruby-forum.com/.
Well, first start with defining the class that represents your polynomials
...
(with proper tests, on "input" and "output" methods).
When that is done, start defining the '==', '+', '*', ... methods
(with proper tests, otherwise you wouldn't pass if I was your professor)
Doing the polynomial division and "find poles" would be fun to
earn better grades ![]()
HTH,
Peter
*** Available for a new project ***
Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v
On Thu, Feb 9, 2012 at 1:09 PM, luk malcik <aport99@gmail.com> wrote:
I need to write + operator for polynomials. How can I do that for
(that's an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
I need to write + operator for polynomials. How can I do that for
(that's an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
class Polynomial
...
def + aPolynomial
your stuff
end
...
end