f | def evalform(formula, *args): | f | def evalform(formula, *args): |
n | var_name = '' | n | id = '' |
| variables = set() | | variables = set() |
| for ch in formula: | | for ch in formula: |
| if ch.isalpha(): | | if ch.isalpha(): |
n | var_name += ch | n | id += ch |
| else: | | else: |
t | if var_name: | t | if id: |
| variables.add(var_name) | | variables.add(id) |
| var_name = '' | | id = '' |
| if var_name: | | if id: |
| variables.add(var_name) | | variables.add(id) |
| values = dict(zip(sorted(variables), args)) | | values = dict(zip(sorted(variables), args)) |
| return eval(formula, values) | | return eval(formula, values) |