rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.76k stars 309 forks source link

Mean of numbers #977

Open xeruf opened 3 months ago

xeruf commented 3 months ago

Would be great to have a helper to calculate the mean of an iterator of items which are both summable and divisable, by summing the elements and then dividing by the amount of elements. In my case useful because I want the mean after calling filter_map, which means I now need to either collect or iterate in a for loop and count up.