Cody

# Problem 2636. Clear all empty variables from the workspace

Solution 1770030

Submitted on 2 Apr 2019 by Abdelfatah Teamah
• Size: 6
• 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
a=1; b=[]; c=500; d=clear_empty(); assert(isequal(exist('a','var'),1)); assert(isequal(exist('b','var'),0)); assert(isequal(exist('c','var'),1)); assert(isequal(exist('d','var'),1));

[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 clear_empty (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
y_correct={}; x_correct=[]; c25=500; John=ones(3); v=clear_empty(); assert(isequal(exist('y_correct','var'),0)); assert(isequal(exist('x_correct','var'),0)); assert(isequal(exist('John','var'),1)); assert(isequal(exist('c25','var'),1)); assert(isequal(exist('v','var'),1));

[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 clear_empty (line 2) In ScoringEngineTestPoint2 (line 5) In solutionTest (line 5)]

3   Pass
j_correct={'John'}; ans1=0; Jane=rand; val=clear_empty(); assert(isequal(exist('j_correct','var'),1)); assert(isequal(exist('Jane','var'),1)); assert(isequal(exist('ans1','var'),1));

[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 clear_empty (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]