Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the dot syntax in Julia function calls

According to Julia documentation, I should be able to call a given (even non-vectorized) function for every element in an array using fun.(A), where A is an array. I try with a simple example and it doesn't seem to work:

julia> x = collect(linspace(0,pi,100));
julia> y = sin.(x)
ERROR: TypeError: getfield: expected Symbol, got Array{Float64,1}

The same error persists with all my own functions. How do I use this feature correctly?

like image 345
Echows Avatar asked Dec 18 '25 00:12

Echows


1 Answers

Just to give this an official answer, this is a new feature that was introduced in Julia 0.5, while @Echows was using Julia 0.4. The solution is to upgrade to Julia 0.5 or newer.

like image 132
StefanKarpinski Avatar answered Dec 21 '25 13:12

StefanKarpinski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!