From: Colin Bartlett Date: 2010-05-14T00:43:24+09:00 Subject: Re: In Ruby, can the coerce() method know what operator it is th On Thu, May 13, 2010 at 3:25 PM, Benoit Daloze wrote: > > :O Google seems to not know me so much then ... > > But, as many Ruby developers, github is the code's home ;) > (while you would hardly find my nickname, except maybe from my email) > http://github.com/eregon/math/tree/master/math I wish I'd known about this http://github.com/eregon/math/blob/master/math/polynomial.rb earlier this year: including differentiation _and_ integration! I was using polynomials to form weighted sums of discrete and continuous actuarial functions, so I needed integration of the polynomials. I couldn't find a polynomial.evaluate method, but polynomial.run(n) seems to give the numerical value of the polynomial for x == n: is that right? ### def -@(); @coef.map! { |c| -c }; end q = Polynomial.new( 2, 3, 1 ) p q #=> 2x^2 + 3x + 1 -q p q #=> - 2x^2 - 3x - 1 If you don't mind me asking, what was the reason for #- changing the polynomial to its negative as opposed to returning a new polynomial which is the negative of the original polynomial?