Cody

# Problem 24. Function Iterator

Solution 1639988

Submitted on 8 Oct 2018 by Philippe S.
• Size: 8
• 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
noOp = @(x)x; fh2 = iterate_fcn(noOp, 50); assert(isequal(fh2(pi),pi));

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

2   Pass

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

3   Pass

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

4   Pass
squarer = @(a) a^2; fh2 = iterate_fcn(squarer, 3); assert(isequal(fh2(3),6561));

[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 iterate_fcn (line 2) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

5   Pass
fh = @(y)sqrt(y+1); fh2 = iterate_fcn(fh,30); assert(abs(fh2(1) - (1+sqrt(5))/2) < 100*eps);

[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 iterate_fcn (line 2) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]