Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4107,6 +4107,7 @@ namespace Microsoft.FSharp.Collections
let start = if i < 0 then 0 else i
PrivateListHelpers.sliceTake (j - start) (PrivateListHelpers.sliceSkip start l)

[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member l.GetReverseIndex(_: int, offset: int) =
l.Length - offset - 1

Expand Down Expand Up @@ -6902,6 +6903,7 @@ namespace Microsoft.FSharp.Core
[<AutoOpen>]
module ArrayExtensions =
type ``[,,,]``<'T> with
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member arr.GetReverseIndex(dim: int, offset: int) =
let len =
match dim with
Expand All @@ -6914,6 +6916,7 @@ namespace Microsoft.FSharp.Core
len - offset - 1

type ``[,,]``<'T> with
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member arr.GetReverseIndex(dim: int, offset: int) =
let len =
match dim with
Expand All @@ -6925,6 +6928,7 @@ namespace Microsoft.FSharp.Core
len - offset - 1

type ``[,]``<'T> with
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member arr.GetReverseIndex(dim: int, offset: int) =
let len =
match dim with
Expand All @@ -6935,9 +6939,11 @@ namespace Microsoft.FSharp.Core
len - offset - 1

type ``[]``<'T> with
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member arr.GetReverseIndex (_: int, offset: int) = arr.Length - offset - 1

type String with
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member str.GetReverseIndex (_: int, offset: int) = str.Length - offset - 1

namespace Microsoft.FSharp.Control
Expand Down
6 changes: 6 additions & 0 deletions src/FSharp.Core/prim-types.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,7 @@ namespace Microsoft.FSharp.Collections
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

/// <summary>Returns a list with <c>head</c> as its first element and <c>tail</c> as its subsequent elements</summary>
Expand Down Expand Up @@ -4608,6 +4609,7 @@ namespace Microsoft.FSharp.Core
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

type ``[,,]``<'T> with
Expand All @@ -4617,6 +4619,7 @@ namespace Microsoft.FSharp.Core
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

type ``[,]``<'T> with
Expand All @@ -4626,6 +4629,7 @@ namespace Microsoft.FSharp.Core
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

type ``[]``<'T> with
Expand All @@ -4635,6 +4639,7 @@ namespace Microsoft.FSharp.Core
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

type System.String with
Expand All @@ -4644,6 +4649,7 @@ namespace Microsoft.FSharp.Core
/// <param name="offset">The offset from the end.</param>
///
/// <returns>The corresponding index from the start.</returns>
[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
member GetReverseIndex: rank: int * offset: int -> int

/// <summary>A module of compiler intrinsic functions for efficient implementations of F# integer ranges
Expand Down