JuliaLang

1 thought
last posted Oct. 13, 2016, 5:51 a.m.
0
get stream as: markdown or atom
1

Optimal way of using simple map() is by avoiding to use lambda function. So for example

dbl(x)=x*2
arr=rand(1000)

non-optimal method is significantly more expensive.

julia> @time map(dbl, arr);
  0.000090 seconds (7 allocations: 8.125 KB)

and by avoiding the use of lambda you get

julia> @time map(x->dbl(x), arr);
  0.040455 seconds (13.77 k allocations: 632.087 KB)