Cody

Solution 1571596

Submitted on 29 Jun 2018
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
incr = @(a)a+1 c = church(0) assert(isequal(c(incr,100),100))

incr = function_handle with value: @(a)a+1 ans = function_handle with value: @(f,x)applyFun(f,x) c = function_handle with value: @(f,x)applyFun(f,x) x = 100

Output argument "ans" (and maybe others) not assigned during call to "church/applyFun". Error in church>@(f,x)applyFun(f,x) (line 3) @(f,x) applyFun(f, x) Error in Test1 (line 3) assert(isequal(c(incr,100),100))

2   Fail
incr = @(a)a+1 c = church(3) assert(isequal(c(incr,0),3))

incr = function_handle with value: @(a)a+1 ans = function_handle with value: @(f,x)applyFun(f,x) c = function_handle with value: @(f,x)applyFun(f,x) x = 0

Undefined function or variable 'ans'. Error in church/applyFun (line 10) ans = f(ans) Error in church>@(f,x)applyFun(f,x) (line 3) @(f,x) applyFun(f, x) Error in Test2 (line 3) assert(isequal(c(incr,0),3))

3   Fail
twice = @(a)a*2 c = church(5) assert(isequal(c(twice,1),32))

twice = function_handle with value: @(a)a*2 ans = function_handle with value: @(f,x)applyFun(f,x) c = function_handle with value: @(f,x)applyFun(f,x) x = 1

Undefined function or variable 'ans'. Error in church/applyFun (line 10) ans = f(ans) Error in church>@(f,x)applyFun(f,x) (line 3) @(f,x) applyFun(f, x) Error in Test3 (line 3) assert(isequal(c(twice,1),32))

4   Fail
incr = @(a)a+1 c = church(10) assert(isequal(c(incr,10),20))

incr = function_handle with value: @(a)a+1 ans = function_handle with value: @(f,x)applyFun(f,x) c = function_handle with value: @(f,x)applyFun(f,x) x = 10

Undefined function or variable 'ans'. Error in church/applyFun (line 10) ans = f(ans) Error in church>@(f,x)applyFun(f,x) (line 3) @(f,x) applyFun(f, x) Error in Test4 (line 3) assert(isequal(c(incr,10),20))

5   Fail
twice = @(a)a*2 c = church(10) assert(isequal(c(twice,3),3072))

twice = function_handle with value: @(a)a*2 ans = function_handle with value: @(f,x)applyFun(f,x) c = function_handle with value: @(f,x)applyFun(f,x) x = 3

Undefined function or variable 'ans'. Error in church/applyFun (line 10) ans = f(ans) Error in church>@(f,x)applyFun(f,x) (line 3) @(f,x) applyFun(f, x) Error in Test5 (line 3) assert(isequal(c(twice,3),3072))