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

feat(corelib): Iterator::fold #7084

Merged
merged 2 commits into from
Jan 15, 2025
Merged

Conversation

MagisterDallis
Copy link
Contributor

Implements Iterator::fold.

Not using a traditional for-loop technique as it's still buggy, as seen in advance_by.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MagisterDallis)


corelib/src/iter/traits/iterator.cairo line 192 at r1 (raw file):

            },
            Option::None => { accum },
        }

Suggestion:

        match Self::next(ref self) {
            Option::None => init,
            Option::Some(x) => Self::fold(ref self, f(init, x), f),
        }

Copy link
Contributor Author

@MagisterDallis MagisterDallis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @orizi)


corelib/src/iter/traits/iterator.cairo line 192 at r1 (raw file):

            },
            Option::None => { accum },
        }

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note it does properly work now - but the recursive implementation is still likely to be a bit more efficient.
:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)


a discussion (no related file):
@gilbens-starkware for 2nd eye.

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)

@orizi orizi enabled auto-merge January 15, 2025 15:48
@orizi orizi added this pull request to the merge queue Jan 15, 2025
Merged via the queue into starkware-libs:main with commit 9a3f075 Jan 15, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants