Hi, I’m looking to calculate nested functions of form f(g(h(...k(x)...)) and have written a function that takes in two arguments. One is called `chain`

which is the vector of `Function`

defined in the order of their calculation and the input array `x`

.

```
function chain_cal(chain:: Vector{Function}, x:: CuArray)
n = size(chain)[1]
for i in 1:n
x = chain[i](x)
end
return x
end
```

I defined a variable `chain`

with two functions named `square`

```
chain = Vector([square, square])
```

```
2-element Array{typeof(square),1}:
square (generic function with 1 method)
square (generic function with 1 method)
```

and when I run `chain_cal`

, I get an error as follows

```
chain_cal(chain, x)
```

```
MethodError: no method matching chain_cal(::Array{typeof(square),1}, ::CuArray{Int64,1})
Closest candidates are:
chain_cal(!Matched::Array{Array{Function,1},1}, ::CuArray) at In[16]:1
chain_cal(!Matched::Array{Function,1}, ::CuArray) at In[31]:1
Stacktrace:
[1] top-level scope at In[35]:1
[2] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091
```

Is there a way where I can modify `chain_cal`

such that it accepts all functions or do I have to modify my earlier defined `square`

function such that it’s type is `Function`

?

```
#=
Square each element in the input CUDA Array
=#
function square(x:: CuArray)
return x.^2
end
```