创建这种形式的 Parallel.ForEach 表达式:
let low = max 1 (k-m)
let high = min (k-1) n
let rangesize = (high+1-low)/(PROCS*3)
Parallel.ForEach(Partitioner.Create(low, high+1, rangesize), (fun j ->
let i = k - j
if x.[i-1] = y.[j-1] then
a.[i] <- b.[i-1] + 1
else
a.[i] <- max c.[i] c.[i-1]
)) |> ignore
导致我收到错误:方法“ForEach”没有重载匹配。但是,我正在使用Parallel.ForEach<TSource>
Method ( Partitioner<TSource>, Action<TSource>
) ,这对我来说似乎是正确的。我错过了什么吗?
编辑:我试图获得与下面的代码相同的结果(不使用分区器):
let low = max 1 (k-m)
let high = min (k-1) n
let rangesize = (high+1-low)/(PROCS*3)
let A = [| low .. high |]
Parallel.ForEach(A, fun (j:int) ->
let i = k - j
if x.[i-1] = y.[j-1] then
a.[i] <- b.[i-1] + 1
else
a.[i] <- max c.[i] c.[i-1]
) |> ignore