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

Accumulate iterator adapter for rust itertools (like itertools.accumulate in Python itertools) #705

Open
evan0greenup opened this issue Jun 18, 2023 · 2 comments

Comments

@evan0greenup
Copy link

I don't find iterator adapter like itertools.accumulate(iterable[, func, *, initial=None]) in Rust itertools.

It would be nice to add it in.

@phimuemue
Copy link
Member

Isn't this scan?

@Philippe-Cholet
Copy link
Member

Philippe-Cholet commented Jun 18, 2023

Yes it very similar to scan but it's not very obvious at first look. With initial=0 and the default func the addition.

(1..8).scan(0, |x, y| { *x += y; Some(*x) })

while people from coming Python would expect something more like

(1..8).some_name(0, |x, y| x + y)

Like in #147

EDIT: Playground example of accumulate[_add] functions.

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

No branches or pull requests

3 participants