Closed zvxryb closed 9 years ago
@MatthewJA, we really need some automated tests for Coffeequate PRs.
@zvxryb, good job on this (and fixing our missing newline at end of file).
@zvxryb: Thanks for this! I noticed that a**2 * b**2
seems to fail, though, due to an infinite recursive loop. I think this is because terms in your loop are not being deep-copied and are thus being mutated (nodes in CQ are mutable). I can fix that when I have time, if you'd like, or you can. If you want to, the relevant method is the .copy()
method that nodes in CQ have.
I tried
Misread that as CQ('a**2 + b**2')
with .solve('a')
, .simplify()
and .toString()
in Firefox and Chromium, both seemed to work OK. Is there a specific operation that it fails for?a**2 + b**2
rather than a**2 * b**2
. I am able to reproduce this issue and I'll look into it further.
Fixed the stack overflow, which was caused by grouping terms with no exponent and simplifying the new subexpression. Also cleaned up side-effects which would have necessitated a deep copy.
Looks good! I'll merge it in.
CQ('a**2 + b**2 = c**2').solve('a')
yields the slightly awkward result +/-sqrt(-(1))*sqrt(b**2 - c**2)
This patch collects common exponents in multiplication, resulting in +/-
sqrt(c**2 - b**2)