@Erno If you want to use the list comprehension and not result-type
Array{Any, 1}, but
Array{Int64, 1} is to define f this way:
f(x)=Int[v[i](x) for i=1:length(v)]
Which yields the exact same result. Just in case you didn't know that. If
you wanted to display the
inherent difference between the result-type of a *map* and
*list-comprehension*, I haven't wrote this.
Stefan
On Monday, November 24, 2014 4:06:21 PM UTC+1, Erno Scheiber wrote:
>
> Differently
>
> a(x)=x^2
> b(x)=x^3
> v=cell(2)
> v[1]=a
> v[2]=b
> f(x)=[v[i](x) for i=1:length(v)]
> # from Stefan Schwarz reply
> g(x)=map(y->y(x),[a,b])
> typeof(f(2))
> Array{Any,1}
> typeof(g(2))
> Array{Int64,1}
>
>
> On Monday, November 24, 2014 10:48:26 AM UTC+2, K leo wrote:
>>
>> I have a bunch of functions with same signature. I would like to invoke
>> them one by one at run time. What is the best way of doing this? Can I
>> put them all in an array or some other collection and loop through it at
>> the run time?
>>
>>