From 5f4fde879c4237f3f990da4507a7c024f7d0ec85 Mon Sep 17 00:00:00 2001 From: Oskar Gewalli Date: Tue, 12 Nov 2024 19:33:38 +0200 Subject: [PATCH] NonEmpty[List|Seq] #if !NET45 --- src/FSharpPlus/Data/NonEmptyList.fs | 12 +++++++++--- src/FSharpPlus/Data/NonEmptySeq.fs | 14 +++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/FSharpPlus/Data/NonEmptyList.fs b/src/FSharpPlus/Data/NonEmptyList.fs index d8f8834cd..86abb2865 100644 --- a/src/FSharpPlus/Data/NonEmptyList.fs +++ b/src/FSharpPlus/Data/NonEmptyList.fs @@ -494,6 +494,7 @@ module NonEmptyList = let init (count: int) (initializer: int -> 'T) : NonEmptyList<'T> = Seq.init count initializer |> ofSeq +#if !NET45 /// Inserts an element at the specified index. /// The index at which to insert the element. /// The value to insert. @@ -509,6 +510,7 @@ module NonEmptyList = /// The result list. let insertManyAt (index: int) (values: seq<'T>) (list: NonEmptyList<'T>) : NonEmptyList<'T> = Seq.insertManyAt index values list |> ofSeq +#endif /// Returns the element at the specified index. /// The index of the element to retrieve. @@ -673,6 +675,7 @@ module NonEmptyList = let inline range (start: 'T) stop = create start (List.drop 1 [start..stop]) +#if !NET45 /// Removes the element at the specified index. /// The index of the element to remove. /// The input list. @@ -704,7 +707,8 @@ module NonEmptyList = /// Thrown when removing the items results in an empty list. let removeManyAt (index: int) (count: int) (list: NonEmptyList<'T>) : NonEmptyList<'T> = list |> Seq.removeManyAt index count |> ofSeq - +#endif + /// Creates a list that contains one repeated value. /// The number of elements. /// The value to replicate. @@ -946,7 +950,8 @@ module NonEmptyList = /// A tuple containing the three lists. let unzip3 (list: NonEmptyList<'T1 * 'T2 * 'T3>) : NonEmptyList<'T1> * NonEmptyList<'T2> * NonEmptyList<'T3> = list |> toList |> List.unzip3 |> fun (a, b, c) -> (ofList a, ofList b, ofList c) - + +#if !NET45 /// Updates the element at the specified index. /// The index of the element to update. /// The new value. @@ -954,7 +959,8 @@ module NonEmptyList = /// The result list. let updateAt (index: int) (value: 'T) (list: NonEmptyList<'T>) : NonEmptyList<'T> = Seq.updateAt index value list |> ofSeq - +#endif + /// Returns a list that contains the elements of the list for which the given function returns true. /// A function to test each element of the list. /// The input list. diff --git a/src/FSharpPlus/Data/NonEmptySeq.fs b/src/FSharpPlus/Data/NonEmptySeq.fs index afea9d162..3aec54c68 100644 --- a/src/FSharpPlus/Data/NonEmptySeq.fs +++ b/src/FSharpPlus/Data/NonEmptySeq.fs @@ -477,7 +477,7 @@ module NonEmptySeq = /// The result sequence. let initInfinite initializer = Seq.initInfinite initializer |> unsafeOfSeq - +#if !NET45 /// Inserts an element at the specified index. /// The index at which to insert the element. /// The value to insert. @@ -493,7 +493,7 @@ module NonEmptySeq = /// The result sequence. let insertManyAt (index: int) (values: seq<'T>) (source: NonEmptySeq<'T>) : NonEmptySeq<'T> = Seq.insertManyAt index values source |> unsafeOfSeq - +#endif /// Returns the element at the specified index. /// The index of the element to retrieve. /// The input sequence. @@ -696,6 +696,7 @@ module NonEmptySeq = let reduceBack (reduction: 'T -> 'T -> 'T) (source: NonEmptySeq<'T>) = Seq.reduceBack reduction source +#if !NET45 /// Removes the element at the specified index. /// The index of the element to remove. /// The input sequence. @@ -727,7 +728,8 @@ module NonEmptySeq = /// Thrown when removing the items results in an empty sequence. let removeManyAt (index: int) (count: int) (source: NonEmptySeq<'T>) : NonEmptySeq<'T> = Seq.removeManyAt index count source |> ofSeq - +#endif + /// Creates a sequence that contains one repeated value. /// The number of elements. /// The value to replicate. @@ -1040,7 +1042,8 @@ module NonEmptySeq = /// A tuple containing the three sequences. let unzip3 (source: NonEmptySeq<'T1 * 'T2 * 'T3>) : NonEmptySeq<'T1> * NonEmptySeq<'T2> * NonEmptySeq<'T3> = source |> Seq.toList |> List.unzip3 |> fun (a, b, c) -> (unsafeOfSeq a, unsafeOfSeq b, unsafeOfSeq c) - + +#if !NET45 /// Updates the element at the specified index. /// The index of the element to update. /// The new value. @@ -1048,7 +1051,8 @@ module NonEmptySeq = /// The result sequence. let updateAt (index: int) (value: 'T) (source: NonEmptySeq<'T>) : NonEmptySeq<'T> = Seq.updateAt index value source |> unsafeOfSeq - +#endif + /// Returns a sequence that contains the elements of the sequence for which the given function returns true. /// A function to test each element of the sequence. /// The input sequence.