Thanks.
On Friday, September 5, 2014 1:02:55 PM UTC+2, Milan Bouchet-Valat wrote: > > Le vendredi 05 septembre 2014 à 03:29 -0700, Földes László a écrit : > > This works fine: > > julia> x = 1:5 > 1:5 > > julia> y = [z^2 for z in x] > 5-element Array{Any,1}: > 1 > 4 > 9 > 16 > 25 > > > and I can use similar solution with a simplified form: > > julia> y = [x*2] > 5-element Array{Int64,1}: > 2 > 4 > 6 > 8 > 10 > > > so I got brave and tried this, but it failed: > > julia> x = 1:5 > 1:5 > > julia> y = [x^2] > ERROR: `*` has no method matching *(::UnitRange{Int64}, ::UnitRange{Int64 > }) > in power_by_squaring at intfuncs.jl:56 > in ^ at intfuncs.jl:86 > > > or: > > julia> y = [x*x] > ERROR: `*` has no method matching *(::StepRange{Int64,Int64}, ::StepRange{ > Int64,Int64}) > > Actually it's even simpler than that: > > julia> x = 1:5 > 1:5 > > julia> x*x > ERROR: `*` has no method matching *(::UnitRange{Int64}, ::UnitRange{Int64}) > > > You want to use .* instead of *, and .^ instead of ^: > julia> x .* x > 5-element Array{Int64,1}: > 1 > 4 > 9 > 16 > 25 > > julia> x.^2 > 5-element Array{Int64,1}: > 1 > 4 > 9 > 16 > 25 > > > Regards >