@everywhere and pmap inside of a function?

This also runs fine for me, even though “smallfunc” isn’t anonymous:

julia> function bigfunc(iterator)
         localvar = 2.5

         function smallfunc(elm)
           # hypothetical (expensive) operation with elm
           # (in my code this is solving a linear system)
           localvar * elm
         end

         pmap(smallfunc, iterator)
       end
bigfunc (generic function with 1 method)

julia> bigfunc(1:10)
10-element Array{Float64,1}:
  2.5
  5.0
  7.5
 10.0
 12.5
 15.0
 17.5
 20.0
 22.5
 25.0
1 Like