Word equations, but not as you know it! Given a sentence which will include two numbers, numerically, and a spelt operator, in the order seen in the examples, your goal is to give the numerical answer
The operators will be spelt as: "add", "minus", "times" and "divide"
Any real number integer may be used, as suggested by caird and Jonathan
The solution must take one input and give one output
Examples:
Input: 7 add 8 Output: 15
Input: 9 times -2 Output: -18
Input: 24 divide 2 Output: 12
Input: 4 minus 5 Output: -1
You are not required to deal with divide by zero errors.
If you use a method that parses the expression, such as the python eval or exec, there will be no penalties, but if possible try to give a another interesting solution
Scoring:
Fewest bytes will win
[7, 'add', 8]
? Or, perhaps less reasonably, as[7, 8]
for one input, and'add'
as a second input? \$\endgroup\$