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...
Is my wife right? Now with even more wrong husband
Reverse the vector
Spot the outlier
Construct an index vector from two input vectors in vectorized fashion
Pernicious Anniversary Problem
Multiples of a Number in a Given Range
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Generate N equally spaced intervals between -L and L
Number of 1s in the Binary Representation of a Number
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