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...
Remove any row in which a NaN appears
First non-zero element in each column
Given a window, how many subsets of a vector sum positive
Height of a right-angled triangle
Find the sides of an isosceles triangle when given its area and height from its base to apex
Determine if a Given Number is a Triangle Number
Return the first and last characters of a character array
Give the Shortest Path Through The Maze
THE CALCULATOR OF LOVE
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