From 53e62f9036c4ade59f4c6353af2ee8ee62688f52 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:07:55 +0000 Subject: [PATCH 1/4] Initial plan From 77f6cabb0baa8b039e082ab8e7ddcd55c6a96e55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:35:45 +0000 Subject: [PATCH 2/4] Add complexity documentation for allPairs, append, average, averageBy, blit, collect Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- src/FSharp.Core/array.fsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/FSharp.Core/array.fsi b/src/FSharp.Core/array.fsi index 18a4463277e..60dac8bff1d 100644 --- a/src/FSharp.Core/array.fsi +++ b/src/FSharp.Core/array.fsi @@ -25,6 +25,11 @@ module Array = /// /// The resulting array of pairs. /// + /// + /// Time Complexity: O(n*m) where n is the length of array1 and m is the length of array2. + /// Space Complexity: O(n*m) for the resulting array. + /// + /// /// /// /// ([| 1; 2 |], [| 3; 4 |]) ||> Array.allPairs @@ -46,6 +51,11 @@ module Array = /// /// Thrown when either of the input arrays is null. /// + /// + /// Time Complexity: O(n+m) where n is the length of array1 and m is the length of array2. + /// Space Complexity: O(n+m) for the resulting array. + /// + /// /// /// /// Array.append [| 1; 2 |] [| 3; 4 |] @@ -64,6 +74,11 @@ module Array = /// /// The average of the elements in the array. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// [| 1.0; 2.0; 6.0 |] |> Array.average @@ -95,6 +110,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// type Foo = { Bar: float } @@ -138,6 +158,8 @@ module Array = /// let target = [| 0; 1; 2; 3; 4; 5 |] /// target[3..4] <- source[1..2] /// + /// Time Complexity: O(count) where count is the number of elements to copy. + /// Space Complexity: O(1). /// /// /// Thrown when either of the input arrays is null. @@ -165,6 +187,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n*k) where n is the length of the input array and k is the average length of the arrays returned by the mapping function. + /// Space Complexity: O(n*k) for the resulting array. + /// + /// /// /// /// type Foo = { Bar: int array } From 14f37e45720bfc635d26989f366113bad910256f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:42:27 +0000 Subject: [PATCH 3/4] Add complexity documentation for 14 more Array functions Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- src/FSharp.Core/array.fsi | 65 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/FSharp.Core/array.fsi b/src/FSharp.Core/array.fsi index 60dac8bff1d..5996f16350e 100644 --- a/src/FSharp.Core/array.fsi +++ b/src/FSharp.Core/array.fsi @@ -230,6 +230,11 @@ module Array = /// Thrown when either of the input arrays /// is null. /// + /// + /// Time Complexity: O(min(n,m)) where n and m are the lengths of the arrays, as comparison stops at the first non-zero result. + /// Space Complexity: O(1). + /// + /// /// /// /// let closerToNextDozen a b = @@ -305,6 +310,11 @@ module Array = /// /// Thrown when the input sequence is null. /// + /// + /// Time Complexity: O(∑|arrays[i]|) where ∑|arrays[i]| is the sum of lengths of all input arrays. + /// Space Complexity: O(∑|arrays[i]|) for the resulting array. + /// + /// /// /// /// let inputs = [ [| 1; 2 |]; [| 3 |]; [| 4; 5 |] ] @@ -325,6 +335,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// [| 1; 2 |] |> Array.contains 2 // evaluates to true @@ -342,6 +357,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// let source = [| 12; 13; 14 |] @@ -364,6 +384,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of unique keys. + /// + /// /// /// /// type Foo = { Bar: string } @@ -386,6 +411,11 @@ module Array = /// /// Thrown when count is negative. /// + /// + /// Time Complexity: O(n) where n is the count. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// Array.create 4 "a" @@ -416,6 +446,11 @@ module Array = /// /// The first element of the array or None. /// + /// + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// + /// /// /// /// let inputs = [| "banana"; "pear" |] @@ -447,6 +482,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// let input = [| 1; 2; 3 |] @@ -478,6 +518,11 @@ module Array = /// Thrown when the input array is null. /// Thrown when either targetIndex or count is negative. /// + /// + /// Time Complexity: O(count) where count is the number of elements to fill. + /// Space Complexity: O(1). + /// + /// /// /// /// let target = [| 0; 1; 2; 3; 4; 5 |] @@ -502,6 +547,11 @@ module Array = /// /// The first result. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// let input = [| 1; 2; 3 |] @@ -534,6 +584,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of elements for which the chooser returns Some. + /// + /// /// /// /// let input = [| Some 1; None; Some 2 |] @@ -660,6 +715,11 @@ module Array = /// Returns an empty array of the given type. /// The empty array. /// + /// + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// + /// /// /// /// Array.empty // Evaluates to [| |] @@ -771,7 +831,10 @@ module Array = /// /// The predicate is applied to the elements of the input array. If any application /// returns true then the overall result is true and no further elements are tested. - /// Otherwise, false is returned. + /// Otherwise, false is returned. + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// /// /// The function to test the input elements. /// The input array. From 276d6f8d068f9da644ec28e7903aa9fa5d85351c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:46:58 +0000 Subject: [PATCH 4/4] Add complexity documentation for 5 more critical Array functions Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- src/FSharp.Core/array.fsi | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/FSharp.Core/array.fsi b/src/FSharp.Core/array.fsi index 5996f16350e..2d12fc7e582 100644 --- a/src/FSharp.Core/array.fsi +++ b/src/FSharp.Core/array.fsi @@ -912,6 +912,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of elements that satisfy the predicate. + /// + /// /// /// /// let inputs = [| 1; 2; 3; 4 |] @@ -1138,6 +1143,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// type Charge = @@ -1620,7 +1630,10 @@ module Array = /// /// The length of the array. /// - /// The notation array.Length is preferred. + /// The notation array.Length is preferred. + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// /// /// Thrown when the input array is null. /// @@ -1670,6 +1683,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// let inputs = [| "a"; "bbb"; "cc" |] @@ -2358,7 +2376,10 @@ module Array = /// Sorts the elements of an array, returning a new array. Elements are compared using . /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. - /// For a stable sort, consider using . + /// For a stable sort, consider using . + /// Time Complexity: O(n log n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// /// /// The input array. ///