4 ms·
plotting x*x1 works but I am not sure why. very interesting graph resulted.
by eatporktoo 14y ago
plotting x*x1 works but I am not sure why. very interesting graph resulted.
- omra 14y agoInteresting! I decided to do some detective work and find out why. I found this: http://imkevinxu.com/xkcd/parser.js 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: $ expression = string_eval("x*x1"); "x*x1" $ expression.split("x").join(12); "12*121" $ expression.split("x").join(3); "3*31" $ expression.split("x").join(0.3); "0.3*0.31" $ expression.split("x").join(-3); "-3*-31"
- imkevinxu 14y agoAwesome 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 :)