我的代码似乎在我的异步工作流程的最后一次迭代后冻结了。它是代码中的一个错误,还是只需要花费很长时间(20分钟加)来完成工作流程?
let rec list_primes x y =
//returns an array with all primes between x and y
if x < y then
if is_prime x (x |> sqrt |> floor) then
printfn "%A" x
x :: list_primes (x + 1.0) y
else
let n_x = x |> next_prime
n_x :: list_primes (n_x + 1.0) y
else
[]
let filt (x:float) =
if x < 10000.0 then
true
else
false
let list_of_primes = List.filter (filt) (list_primes 1000.0 10000.0)
let iter = [0..((List.length list_of_primes)-3)]
let equal_difference (list:List<float>) iter =
printfn "%A" iter
async{
let mutable a = [|[||]|]
for x in (iter + 1)..(list.Length - 1) do
printfn "inside loop, x = %A" x
let temp = test_sum_in_list list.[x] list.[iter] list
//let temp1 = test_sum_in_list (list.[x] + list.[iter]) list.[x] list
if temp then
a <- Array.append a [|[|list.[x]; list.[iter]; (list.[x] + list.[iter]);|]|]
printf "added %A" a
let result = a
return result
}
let result = iter
|> List.map (equal_difference list_of_primes)
|> Async.Parallel
|> Async.RunSynchronously