Try y = x.^2
--Tim

On Friday, September 05, 2014 03:29:37 AM Földes László wrote:
> 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})

Reply via email to