Cody

# Problem 44382. Parse me a Lisp

Solution 1391744

Submitted on 23 Dec 2017 by Brendan Gray
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));

[1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [(+ 1 1 1 1 1)] = 5.000000

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

[1] = 1.000000 [5] = 5.000000 [(+ 1 5)] = 6.000000

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

[1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [1] = 1.000000 [(+ 1 1 1 1 1 1 1 1 1 1 1 1 1)] = 13.000000

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

[1] = 1.000000 [2] = 2.000000 [3] = 3.000000 [4] = 4.000000 [5] = 5.000000 [6] = 6.000000 [7] = 7.000000 [8] = 8.000000 [9] = 9.000000 [10] = 10.000000 [(+ 1 2 3 4 5 6 7 8 9 10)] = 55.000000

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

[1] = 1.000000 [2] = 2.000000 [3] = 3.000000 [4] = 4.000000 [5] = 5.000000 [6] = 6.000000 [7] = 7.000000 [8] = 8.000000 [9] = 9.000000 [10] = 10.000000 [(* 1 2 3 4 5 6 7 8 9 10)] = 3628800.000000

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

[10] = 10.000000 [1] = 1.000000 [4] = 4.000000 [(+ 1 4)] = 5.000000 [(* 10 (+ 1 4))] = 50.000000 [10] = 10.000000 [12] = 12.000000 [2] = 2.000000 [3] = 3.000000 [(/ 12 2 3)] = 2.000000 [1] = 1.000000 [(+ 10 (/ 12 2 3) 1)] = 13.000000 [0.1] = 0.100000 [(* (* 10 (+ 1 4)) (+ 10 (/ 12 2 3) 1) 0.1)] = 65.000000