This is something more subtle than that:

In [3]:

[(x->x)(x) for x in [1,2,3]]

Out[3]:

3-element Array{Int64,1}:
 1
 2
 3



On Sunday, February 16, 2014 6:36:48 PM UTC-6, Fil Mackay wrote:
>
> What is the reason that anonymous functions lose their typing information 
> as per below:
>
> julia> f = i->i
> (anonymous function)
>
> julia> [f(x) for x in [1,2,3]]
> 3-element Array{*Any*,1}:
>  1
>  2
>  3
>
> julia> function fn(i)
>          i
>        end
> fn (generic function with 1 method)
>
> julia> [fn(x) for x in [1,2,3]]
> 3-element Array{*Int64*,1}:
>  1
>  2
>  3
>
> Presumably this means anonymous functions cannot be used in many contexts..
>
>

Reply via email to