-
Notifications
You must be signed in to change notification settings - Fork 308
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
Something like all_same? #175
Comments
Hm first approach, is there a neat way to do that already? There is: iter.tuple_windows().all(|(x, y)| x == y)
// but this requires cloning elements (irrelevant if they are integers or references) There is (weird one): all_equal == iter.dedup().nth(1).is_none() // only zero or one unique elements I haven't had the need for this operation, I can see that current itertools doesn't cover it very well. |
Thank you for your reply. Actually, I found out that in my concrete case, there is another - more natural - way avoiding However, I still think that it might be useful, especially within I do not know how the dedup actually works, so I can not tell whether |
dedup is lazy and only looks at adjacent elements so it should be close to doing the minimal work required (this is without me cross checking with the implementation). |
This method needs a better name. With |
I think you are correct that a However, I saw that |
I think it needs to remember last. Otherwise, why not prove it with an implementation 😄 |
Should we close this? |
Sure. Fixed in #196 |
Do you think it would be helpful to have something that determines whether all elements of an iterator are the same?
The text was updated successfully, but these errors were encountered: