Skip to content

Commit 1f547ca

Browse files
committed
Implement TaskSeq.findIndex/tryFindIndex/findIndexAsync/tryFindIndexAsync and add tests, docs
1 parent db64dbc commit 1f547ca

File tree

6 files changed

+559
-4
lines changed

6 files changed

+559
-4
lines changed

src/FSharpy.TaskSeq.Test/FSharpy.TaskSeq.Test.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Compile Include="TaskSeq.Empty.Tests.fs" />
1919
<Compile Include="TaskSeq.ExactlyOne.Tests.fs" />
2020
<Compile Include="TaskSeq.Filter.Tests.fs" />
21+
<Compile Include="TaskSeq.FindIndex.Tests.fs" />
2122
<Compile Include="TaskSeq.Find.Tests.fs" />
2223
<Compile Include="TaskSeq.Fold.Tests.fs" />
2324
<Compile Include="TaskSeq.Head.Tests.fs" />

src/FSharpy.TaskSeq.Test/TaskSeq.Find.Tests.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ module SideEffects =
206206
found |> should equal 3
207207
i |> should equal 3 // only partial evaluation!
208208

209-
// find next item. We do get a new iterator, but mutable state is now starting at '3'
209+
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
210210
let! found = ts |> TaskSeq.find ((=) 4)
211211
found |> should equal 4
212212
i |> should equal 4 // only partial evaluation!
@@ -226,7 +226,7 @@ module SideEffects =
226226
found |> should equal 3
227227
i |> should equal 3 // only partial evaluation!
228228

229-
// find next item. We do get a new iterator, but mutable state is now starting at '3'
229+
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
230230
let! found = ts |> TaskSeq.findAsync (fun x -> task { return x = 4 })
231231
found |> should equal 4
232232
i |> should equal 4
@@ -360,7 +360,7 @@ module SideEffects =
360360
found |> should equal (Some 3)
361361
i |> should equal 3 // only partial evaluation!
362362

363-
// find next item. We do get a new iterator, but mutable state is now starting at '3'
363+
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
364364
let! found = ts |> TaskSeq.tryFind ((=) 4)
365365
found |> should equal (Some 4)
366366
i |> should equal 4 // only partial evaluation!
@@ -380,7 +380,7 @@ module SideEffects =
380380
found |> should equal (Some 3)
381381
i |> should equal 3 // only partial evaluation!
382382

383-
// find next item. We do get a new iterator, but mutable state is now starting at '3'
383+
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
384384
let! found = ts |> TaskSeq.tryFindAsync (fun x -> task { return x = 4 })
385385
found |> should equal (Some 4)
386386
i |> should equal 4

0 commit comments

Comments
 (0)