You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The examples of count and any_of implemented using reduce aren't correct: https://github.com/codereport/Algorithms/blob/master/stl_14_reduce_accumulate.cpp. Because reduce can be applied out of order, you have to have associative, commutative functions. The functions being passed here don't even expect the same type for their left and right argument, so they're clearly not commutative. They could be changed to use accumulate, although in the case of any_of you're still better off using find_if.
The text was updated successfully, but these errors were encountered:
The examples of count and any_of implemented using reduce aren't correct: https://github.com/codereport/Algorithms/blob/master/stl_14_reduce_accumulate.cpp. Because reduce can be applied out of order, you have to have associative, commutative functions. The functions being passed here don't even expect the same type for their left and right argument, so they're clearly not commutative. They could be changed to use accumulate, although in the case of any_of you're still better off using find_if.
The text was updated successfully, but these errors were encountered: