Cody

Problem 44382. Parse me a Lisp

Solution 1770002

Submitted on 2 Apr 2019 by Abdelfatah Teamah
• Size: 7
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
expr = "(+ 1 1 1 1 1)"; assert(isequal(eval_lisp(expr), 5));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3)]

2   Pass
expr = "(+ 1 5)"; assert(isequal(eval_lisp(expr), 6));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

3   Pass
expr = "(+ 1 1 1 1 1 1 1 1 1 1 1 1 1)"; assert(isequal(eval_lisp(expr), 13));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

4   Pass
expr = "(+ 1 2 3 4 5 6 7 8 9 10)"; assert(isequal(eval_lisp(expr), 55));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

5   Pass
expr = "(* 1 2 3 4 5 6 7 8 9 10)"; assert(isequal(eval_lisp(expr), 3628800));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]

6   Pass
expr = "(* (* 10 (+ 1 4)) (+ 10 (/ 12 2 3) 1) 0.1)"; assert(isequal(eval_lisp(expr), 65));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In eval_lisp (line 2) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)]