nessos / Streams

A lightweight F#/C# library for efficient functional-style pipelines on streams of data.
http://nessos.github.io/Streams/
Other
381 stars 46 forks source link

ParStream.filter followed by ParStream.mapi gives incorrect results when iterated #36

Closed dsyme closed 9 years ago

dsyme commented 9 years ago

I believe ParStream.iter needs to check for if stream.PreserveOrdering then...

Repro:

ParStream.ofArray [| 101 .. 201 |] 
  |> ParStream.filter (fun x -> x % 2 = 0) 
  |> ParStream.mapi (fun i x -> (i,x)) 
  |> ParStream.iter (printfn "%A")

gives

(25, 126)
(1, 102)
(51, 152)
(3, 104)
(27, 128)
(53, 154)
(5, 106)
(29, 130)
(31, 132)
(7, 108)
(55, 156)
(33, 134)
(9, 110)
(57, 158)
(35, 136)
(11, 112)
(59, 160)
(37, 138)
(13, 114)
(15, 116)
(39, 140)
(61, 162)
(17, 118)
(41, 142)
(63, 164)
(19, 120)
(43, 144)
(65, 166)
(21, 122)
(45, 146)
(23, 124)
(47, 148)
(67, 168)
(75, 176)
(49, 150)
(69, 170)
(77, 178)
(71, 172)
(79, 180)
(73, 174)
(81, 182)
(83, 184)
(85, 186)
(87, 188)
(89, 190)
(91, 192)
(93, 194)
(95, 196)
(97, 198)
(99, 200)