Re: [pure-lang-users] equations in Q vs Pure
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-07-26 10:54:29
|
On Sat 26/07/08 2:49 AM , Albert Graef Dr....@t-... sent: > Because that rule doesn't apply. Note that x^2+3*x+4*x+12 === > (x^2+3*x)+4*x+12 !== x^2+(3*x+4*x)+12. Pure doesn't do any rewriting > modulo AC (associativity+commutativity). Neither does Q, it will return > exactly the same result with your equations. > > What you can do to make this example work is add the following rule: > > x+(a*b)+(c*d) = x+(a+c)*b if b === d; Ah! Ok, the reason why I was getting the answer in Q is because I also had the associative rules of multiplication and addition. (a+b)+c = a+(b+c); It works but x^2+(7x+12) is kind of annoying to look at. The rule you give above makes the answer look nice. Thanks, e.r. |