Writing a simple equation parser

前端 未结 10 1185
-上瘾入骨i
-上瘾入骨i 2020-12-01 03:56

What sorts of algorithms would be used to do this (as in, this is a string, and I want to find the answer):

((5 + (3 + (7 * 2))) - (8 * 9)) / 72
10条回答
  •  猫巷女王i
    2020-12-01 04:23

    Or you can just do this in one line in R:

    > eval(parse(text = '((5 + (3 + (7*2))) - (8 * 9))/72' ))
    [1] -0.6944444
    

提交回复
热议问题