File tree 3 files changed +14
-6
lines changed
3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
- namespace FSharpPlus.Control
2
-
3
1
/// <namespacedoc>
4
2
/// <summary>
5
3
/// Generally internal and not useful directly - contains generic function overloaded implementations.
6
4
/// </summary>
7
5
/// </namespacedoc>
6
+ namespace FSharpPlus.Control
8
7
9
8
#if (! FABLE_ COMPILER || FABLE_ COMPILER_ 3) && ! FABLE_ COMPILER_ 4
10
9
Original file line number Diff line number Diff line change 1
1
namespace FSharpPlus
2
2
3
- #if ! FABLE_ COMPILER
4
-
5
3
/// Additional operations IList<'T>
6
4
[<RequireQualifiedAccess>]
7
5
module IList =
@@ -14,4 +12,8 @@ module IList =
14
12
/// <returns>The list converted to a System.Collections.Generic.IReadOnlyList</returns>
15
13
let toIReadOnlyList ( source : IList < _ >) = ReadOnlyCollection source :> IReadOnlyList<_>
16
14
17
- #endif
15
+ let ofArray ( source : 'T [] ) = source :> IList< 'T>
16
+ let ofList ( source : 'T list ) = source |> Array.ofList :> IList< 'T>
17
+ let ofSeq ( source : seq < 'T >) = source |> Array.ofSeq :> IList< 'T>
18
+ let map mapping ( source : IList < 'T >) = Seq.map mapping source |> Seq.toArray :> IList< 'U>
19
+ let iter mapping ( source : IList < 'T >) = Seq.iter mapping source
Original file line number Diff line number Diff line change @@ -19,8 +19,15 @@ module IReadOnlyList =
19
19
if 0 <= i && i < source.Count then
20
20
source |> Array.ofSeq |> setNth i value |> ofArray |> Some
21
21
else None
22
+
23
+ let ofList ( source : 'T list ) = source |> Array.ofList |> IList.toIReadOnlyList
24
+ let ofSeq ( source : seq < 'T >) = source |> Array.ofSeq |> IList.toIReadOnlyList
25
+
22
26
#endif
23
27
24
28
let tryItem i ( source : IReadOnlyList < _ >) =
25
29
if 0 <= i && i < source.Count then Some source.[ i]
26
- else None
30
+ else None
31
+
32
+ let map mapping ( source : IReadOnlyList < 'T >) : IReadOnlyList < 'U > = Seq.map mapping source |> Seq.toArray |> IList.toIReadOnlyList
33
+ let iter mapping ( source : IReadOnlyList < 'T >) = Seq.iter mapping source
You can’t perform that action at this time.
0 commit comments