[pure-lang-users] equations in Q vs Pure
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-07-25 19:32:33
|
Hi guys! In Q we could write: (X+A)*(X+B) = X^2+(A+B)*X+(A*B); as an equation and Q would happily reduce (X+2)*(X+4); to X^2+6*X+8 which was nice. But in Pure, since we cannot repeat a variable on the left hand side, we cannot do any of these nice equations: X*Y+X*Z = X*(Y+Z); X/X = 1 if X != 0; X+N*X = (N+1)*X; etc... Albert, I know you made an === operator but how are we suppose to use it to handle this sort of stuff? Ok. I've figured I need to do stuff like (a*b)+(c*d) = (a+c)*b if b === d; a*b=a^2 if a===b; (a+b)*(c+d) = a*c+a*d+b*c+b*d; a*b = b*a if numberp b; Then > (x+4)*(x+3) x^2+3*x+4*x+12 Why doesn't the rule '(a*b)+(c*d) = (a+c)*b if b === d;' reduce it further to x^2+7x+12 since > 3*x+4*x reduces to 7*x e.r. |