Interesting! I decided to do some detective work and find out why. I found this: http://imkevinxu.com/xkcd/parser.js, and thought that maybe if I knew how the strings were parsed, I could figure out why it was doing that.
$ string_eval("x*x1")
"x*x1"
I figured that the issue must be with the equation drawing or evaluated. Here's what I found as an inline script (note that i is points at which the function is evaluated):
current_expression = expression.split("-x").join(-i);
var result = eval(current_expression.split("x").join(i));
So it just splits up the equation and rejoins it. From here it was pretty easy to see what was happening:
Awesome detective work there! Yes you are correct, the basics of the parser is that it is just replacing values for x and while I did a check for 10x to be 10x, I did not check for x10 to turn into x10.
Just pushed the bug fix, should work now! Hacker News is awesome, thanks :)
omra|13 years ago
imkevinxu|13 years ago
Just pushed the bug fix, should work now! Hacker News is awesome, thanks :)