A couple of questions about pmap

  1. How to transfer a double cycle to pmap?
    pmap(myfun, for i in 1:100 for j in 10:120)

  2. If pmap does not return the result, does the syntax of the pmap call change?
    pmap(myfun, forend)

  1. In v0.6:
julia> f(x,y) = x-y
f (generic function with 1 method)

julia> @inline f(x) = f(x...)
f (generic function with 2 methods)

julia> pmap(f, ((i,j) for i in 1:5, j in 1:5))
5×5 Array{Int64,2}:
 0  -1  -2  -3  -4
 1   0  -1  -2  -3
 2   1   0  -1  -2
 3   2   1   0  -1
 4   3   2   1   0

In v0.7:

julia> using Distributed

julia> f((x,y)) = x-y
f (generic function with 1 method)

julia> pmap(f, ((i,j) for i in 1:5, j in 1:5))
5×5 Array{Int64,2}:
 0  -1  -2  -3  -4
 1   0  -1  -2  -3
 2   1   0  -1  -2
 3   2   1   0  -1
 4   3   2   1   0
  1. Not that I know of.
3 Likes

Thank you!