使用Julia';s pmap()与理解

使用Julia';s pmap()与理解,julia,pmap,Julia,Pmap,使用一个简单的函数,例如 function fun(x::Real, y::Real) x, y end 我想通过执行以下操作使用pmap()调用 朱莉娅给出了这个错误 ERROR: LoadError: MethodError: Cannot `convert` an object of type Tuple{Float64,Float64} to an object of type AbstractFloat This may have arisen from a call to

使用一个简单的函数,例如

function fun(x::Real, y::Real)
    x, y
end
我想通过执行以下操作使用pmap()调用

朱莉娅给出了这个错误

ERROR: LoadError: MethodError: Cannot `convert` an object of type Tuple{Float64,Float64} to an object of type AbstractFloat
This may have arisen from a call to the constructor AbstractFloat(...),
since type constructors fall back to convert methods.
我真的不明白这里发生了什么

根据我所做的一些研究:

It's well-established that to call map on an N-argument function, you pass N lists (or whatever collection) to map:

julia> map(+, (1,2), (3,4))
(4,6)

那怎么了?

您使用的是哪个版本的Julia?请更新到最新的稳定版本(0.6.x),由于此版本与当前版本配合良好,因此此示例在JuliaBox上运行:


jrun@notebook-0hnhf:/home/jrun$julia
_
_一种新的技术计算方法
文件:https://docs.julialang.org
_| | | | | | | |键入“?帮助”以获取帮助。
| | | | | | |/ _' |  |
|| | | | | | | | |版本0.6.2(2017-12-13 18:08 UTC)
_/官员http://julialang.org/ 释放
|__/| x86_64-pc-linux-gnu'
julia>函数乐趣(x::Real,y::Real)
x、 y
结束
fun(通用函数和1个方法)
julia>pmap(有趣,[x代表x=0:.1:2],[y代表y=4:-.1:2])
21元素数组{Tuple{Float64,Float64},1}:
(0.0, 4.0)
(0.1, 3.9)
(0.2, 3.8)
(0.3, 3.7)
(0.4, 3.6)
(0.5, 3.5)
(0.6, 3.4)
(0.7, 3.3)
(0.8, 3.2)
(0.9, 3.1)
(1.0, 3.0)
(1.1, 2.9)
(1.2, 2.8)
(1.3, 2.7)
(1.4, 2.6)
(1.5, 2.5)
(1.6, 2.4)
(1.7, 2.3)
(1.8, 2.2)
(1.9, 2.1)
(2.0, 2.0)
如果您不打算转换或过滤范围内收集的元素,那么您也可以简单地调用
collect(4:-.1:2)
,而不是
[y=4:-.1:2]

如果您只需要迭代范围的值,那么您甚至不需要收集值,只需按原样使用范围,即:

pmap(乐趣,0:1:2,4:-.1:2)

我也在使用0.6.2,但x86_64-w64-mingw32。好的,理解和范围不起作用,原因不明,但collect()确实起作用。也许我的Julia安装有问题。谢谢你的帮助。
It's well-established that to call map on an N-argument function, you pass N lists (or whatever collection) to map:

julia> map(+, (1,2), (3,4))
(4,6)