Andrew Nelson
2015-12-17 04:52:03 UTC
Dear pyparsing users,
I'm attempting to make a fully functional scientific calculator by
expanding on some example code I found on the pyparsing wiki. The code
I have so far is at:
http://pastebin.com/aAPri29k
6.6, 'H':7.7, 'I':8.8, 'J':9.9, "abc": 20}
So far so good. However, I would now like to use functions which have
more that one parameter, e.g. math.pow or math.atan2.
I've been trying all day to add this kind of functionality, but
failing miserably. I've mainly been experimenting with delimitedList:
listop = delimitedList(operand)
and adding this listop to the infixNotation call.
Can anyone inform me if there is a simple solution? I'm a total novice
at parsing.
regards,
Andrew.
_____________________________________
Dr. Andrew Nelson
_____________________________________
------------------------------------------------------------------------------
I'm attempting to make a fully functional scientific calculator by
expanding on some example code I found on the pyparsing wiki. The code
I have so far is at:
http://pastebin.com/aAPri29k
6.6, 'H':7.7, 'I':8.8, 'J':9.9, "abc": 20}
arith = Arith( vars_ )
arith.eval("1+2*sin(B)*2")
4.564829440245742arith.eval("1+2*sin(B)*2")
So far so good. However, I would now like to use functions which have
more that one parameter, e.g. math.pow or math.atan2.
I've been trying all day to add this kind of functionality, but
failing miserably. I've mainly been experimenting with delimitedList:
listop = delimitedList(operand)
and adding this listop to the infixNotation call.
Can anyone inform me if there is a simple solution? I'm a total novice
at parsing.
regards,
Andrew.
_____________________________________
Dr. Andrew Nelson
_____________________________________
------------------------------------------------------------------------------