Cody

# Problem 582. Function composition - harder

Solution 1253044

Submitted on 18 Aug 2017
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   Fail
f1 = @(x)x+1; f2 = @(x)3*x; f3 = @sqrt; h = composeFcn(f1,f2,f3); assert(isequal(h(9),10));

h = function_handle with value: @(x)1 f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x))

Assertion failed.

2   Fail
f = repmat({@(x)x+1},1,100); h = composeFcn(f{:}); assert(isequal(h(0),100));

h = function_handle with value: @(x)1 f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)varargin{i}(x) h...

Assertion failed.

3   Fail
f = @(x)x; h = composeFcn(f); assert(isequal(h(1234),1234));

h = function_handle with value: @(x)1 f = function_handle with value: @(x)varargin{i}(x) h = function_handle with value: @(x)f(h(x))

Assertion failed.