Problem 57820. Easy Sequences 103: One-line Code Challenge - Evaluate String Math Expressions
Given a character string of a simple mathematical expression containing only numbers, parentheses and arithmetic symbols (+ - * /), write a function that evaluates the value of the string expression. If the input is an empty string or when no arguments are passed to the function, the function should output the value of the previous non-empty expression evaluated.
The following restrictions apply:
- The function should only have one (1) line of code, excluding the function start line.
- Semicolons (;) are considered end-of-line characters.
- Please suppress the function end line. Keyword 'end' is not allowed.
- Regular expressions and string manipulation are not allowed.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers1
Suggested Problems
-
Maximum running product for a string of numbers
2152 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1082 Solvers
-
Matrix indexing with two vectors of indices
718 Solvers
-
find the maximum element of the matrix
490 Solvers
-
610 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!