it seems look-up table solutions are becoming a bit of an issue, could you please add a few test cases to discourage this? +1 for random test cases that are a bit harder to trick, for example something like n=randi(100,1,randi(10)); expr = "(+" + string(num2str(n))+ ")"; assert(isequal(eval_lisp(expr), sum(n)));
I think another test case with multiple expressions would be equally useful. Even something as simple as (+ 1 (* 2 3) 4) would prevent some of the look-up solutions. Make some of those values random, and it will work even better.
Good problem, and better than 44374. Precedence is clear.
Nice. I was trying to figure out how to use strtok, but couldn't quite come up with it.
Are you sure that your Test Suite works? I had to change all the double quotes to single quotes.
Double-quoted strings are string literals in MATLAB R2017a+. To convert a string to char array, use the "char" function.
Thank you for that hint about the "char", bmtran. Never would have figured out what was wrong with my solution otherwise...
Maximum running product for a string of numbers
Tell me the slope
Create a square matrix of multiples
Get the elements of diagonal and antidiagonal for any m-by-n matrix
Return the first and last characters of a character array
First N Perfect Squares
THE CALCULATOR OF LOVE
Test if a Number is a Palindrome without using any String Operations
Return the 'Size' of a String of Code
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office