Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in buffered Window implementations #577

Closed
viceroypenguin opened this issue Nov 22, 2023 · 0 comments · Fixed by #586
Closed

Bug in buffered Window implementations #577

viceroypenguin opened this issue Nov 22, 2023 · 0 comments · Fixed by #586
Labels
bug Something isn't working
Milestone

Comments

@viceroypenguin
Copy link
Owner

Given the following code:

var sequence = Enumerable.Range(1, 10);

// Break the sequence of numbers into three chunks of 3 and one chunk of 1
var buffer = new int[5];
var result = sequence
	.Window(
		buffer,
		3,
		c => "   [" + string.Join(", ", c) + "]");

Console.WriteLine(
	"[" + Environment.NewLine +
	string.Join(
		", " + Environment.NewLine,
		result) +
	Environment.NewLine + "]");

Expected values:

// This code produces the following output:
// [
//    [1, 2, 3],
//    [2, 3, 4],
//    [3, 4, 5],
//    [4, 5, 6],
//    [5, 6, 7],
//    [6, 7, 8],
//    [7, 8, 9],
//    [8, 9, 10]
// ]

Actual values:

// This code produces the following output:
// [
//    [1, 2, 3],
//    [2, 3, 0, 0, 4],
//    [3, 0, 0, 4, 5],
//    [0, 0, 4, 5, 6],
//    [0, 4, 5, 6, 7],
//    [4, 5, 6, 7, 8],
//    [5, 6, 7, 8, 9],
//    [6, 7, 8, 9, 10]
// ]
@viceroypenguin viceroypenguin added the bug Something isn't working label Nov 22, 2023
@viceroypenguin viceroypenguin added this to the 5.4.0 milestone Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant