phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Fix Issue 24541 - cartesianProduct should have a length for finite ranges

Open nicolo-mn opened this issue 9 months ago • 3 comments

This Draft PR aims to address issue #9871 (Issue 24541 on BugZilla). As of now, I have added a length field to the cartesianProduct implementation with two finite forward ranges. Since I've already built the unittests for it I'm publishing this Draft PR in case anyone wants to give some feedback. I'm still working on the case of two finite ranges where one of them is not a forward range, particularly to replace the joiner returned in cartesianProduct with a sized range.

Changelog as of now:

  • Modified the Result struct inside cartesianProduct to include a length field.
  • Added checks on length in unittest regarding cartesianProduct with finite forward ranges.
  • Added a unittest to ensure the correct calculation of length when popping elements.

nicolo-mn avatar Mar 02 '25 16:03 nicolo-mn

Thanks for your pull request and interest in making D better, @nicolo-mn! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#10657"

dlang-bot avatar Mar 02 '25 16:03 dlang-bot

length field in cartesianProduct with one finite input range and one finite forward range has been added

nicolo-mn avatar Mar 04 '25 14:03 nicolo-mn

@thewilsonator Could you check my changes when you got some time? Thanks in advance!

nicolo-mn avatar Mar 06 '25 09:03 nicolo-mn