File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 1- namespace FSharpPlus.Control
2-
31/// <namespacedoc>
42/// <summary>
53/// Generally internal and not useful directly - contains generic function overloaded implementations.
64/// </summary>
75/// </namespacedoc>
6+ namespace FSharpPlus.Control
87
98#if (! FABLE_ COMPILER || FABLE_ COMPILER_ 3) && ! FABLE_ COMPILER_ 4
109
Original file line number Diff line number Diff line change 11namespace FSharpPlus
22
3- #if ! FABLE_ COMPILER
4-
53/// Additional operations IList<'T>
64[<RequireQualifiedAccess>]
75module IList =
@@ -14,4 +12,8 @@ module IList =
1412 /// <returns>The list converted to a System.Collections.Generic.IReadOnlyList</returns>
1513 let toIReadOnlyList ( source : IList < _ >) = ReadOnlyCollection source :> IReadOnlyList<_>
1614
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 =
1919 if 0 <= i && i < source.Count then
2020 source |> Array.ofSeq |> setNth i value |> ofArray |> Some
2121 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+
2226 #endif
2327
2428 let tryItem i ( source : IReadOnlyList < _ >) =
2529 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