This project is read-only.
2
Vote

PSeq.map returning incorrect results

description

The PSeq.map function does not seem to be order preserving:
 
let u = [|1N..10000000N|]
u |> PSeq.map (fun n -> n / (1N + n)) |> Array.ofSeq
val it : BigRational [] =
[|6250001/6250002N; 8750001/8750002N; 1/2N; ...
 
a workaround for this can be:
 
u
|> System.Linq.ParallelEnumerable.AsParallel
|> System.Linq.ParallelEnumerable.AsOrdered
|> PSeq.map (fun n -> n / (1N + n))
|> Array.ofSeq

comments