mentat-collective / emmy

The Emmy Computer Algebra System.

Home Page:https://emmy.mentat.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unary negation handling is broken in ->JavaScript

littleredcomputer opened this issue · comments

Minimal repro:

user=> (->JavaScript (simplify (* -2 (+ 'x 'y))))
"function(x, y) {\n  return -2 * x -2 * y;\n}"

This may work, but it looks like it has promoted the -2 from unary negation to binary subtract, which I find suspicious. Can this be correct in all cases?

Oh yeah, another one I ran into had to do with dashes being illegal... we need to transform them to underscores.

I think we may have been getting away with this, but I'm going to make it a bit more principled instead of just looking for an initial hyphen in the string rep of the next term in the sum. Also, will make it work for -k instead of just -1

Just checked to see if this was fixed by CSE and it looks like it's still an issue.