From 0b8db575d44f2d873517840c85691a18499de05e Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 15 Feb 2026 12:46:03 +0200 Subject: [PATCH 1/2] Fix misleading Seq.init XML doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The doc claimed "Each element is saved after its initialization" but Seq.init does not cache elements — the initializer function is reapplied on each iteration, same as Seq.initInfinite. Update the description to match actual behavior and add a reference to Seq.cache for users who need cached results. Fixes #14233 --- src/FSharp.Core/seq.fsi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/FSharp.Core/seq.fsi b/src/FSharp.Core/seq.fsi index dfb7f79dd7..9adf5a412c 100644 --- a/src/FSharp.Core/seq.fsi +++ b/src/FSharp.Core/seq.fsi @@ -1325,12 +1325,13 @@ module Seq = val indexed: source: seq<'T> -> seq /// Generates a new sequence which, when iterated, will return successive - /// elements by calling the given function, up to the given count. Each element is saved after its - /// initialization. The function is passed the index of the item being - /// generated. + /// elements by calling the given function, up to the given count. The results of calling the function + /// will not be saved, that is the function will be reapplied as necessary to + /// regenerate the elements. The function is passed the index of the item being + /// generated. To cache the results, see . /// /// The returned sequence may be passed between threads safely. However, - /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. This is an O(n) operation, where n is the count. + /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. /// /// The maximum number of items to generate for the sequence. /// A function that generates an item in the sequence from a given index. From 689bbcf8065bba0defa6c4210d443c882cea25b9 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 16 Feb 2026 22:22:00 +0200 Subject: [PATCH 2/2] Restore complexity docs with construction/enumeration split --- src/FSharp.Core/seq.fsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FSharp.Core/seq.fsi b/src/FSharp.Core/seq.fsi index 9adf5a412c..b793b63e6d 100644 --- a/src/FSharp.Core/seq.fsi +++ b/src/FSharp.Core/seq.fsi @@ -1331,7 +1331,9 @@ module Seq = /// generated. To cache the results, see . /// /// The returned sequence may be passed between threads safely. However, - /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// Construction of the sequence object is an O(1) operation. Each enumeration is an O(n) operation, where n is the count, + /// invoking the initializer function once per element. /// /// The maximum number of items to generate for the sequence. /// A function that generates an item in the sequence from a given index.