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...
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
expr = "(+ 1 1 1 1 1)";
assert(isequal(eval_lisp(expr), 5));
|
2 | Fail |
expr = "(+ 1 5)";
assert(isequal(eval_lisp(expr), 6));
|
3 | Fail |
expr = "(+ 1 1 1 1 1 1 1 1 1 1 1 1 1)";
assert(isequal(eval_lisp(expr), 13));
|
4 | Fail |
expr = "(+ 1 2 3 4 5 6 7 8 9 10)";
assert(isequal(eval_lisp(expr), 55));
|
5 | Fail |
expr = "(* 1 2 3 4 5 6 7 8 9 10)";
assert(isequal(eval_lisp(expr), 3628800));
|
6 | Fail |
expr = "(* (* 10 (+ 1 4)) (+ 10 (/ 12 2 3) 1) 0.1)";
assert(isequal(eval_lisp(expr), 65));
|
468 Solvers
Back to basics 13 - Input variables
203 Solvers
1317 Solvers
Compute a dot product of two vectors x and y
645 Solvers
162 Solvers