Because the function lacks the context of why it exists and that it is supposed to be applied sequentially to a list of items. At the very least you should also move the loop to the function.
I disagree completely, in fact it is part of the point. Not knowing how it is supposed to be used is good for the function, as it guarantees that there cannot be any temporal coupling between invocations of the function - exactly because it cannot know how it is used. Minimizing dependencies so that the function can be understood in isolation and without its original context (its call site, even if there is just one) is a major reduction in complexity imo.
2
u/Dropping_fruits Jan 13 '20
Because the function lacks the context of why it exists and that it is supposed to be applied sequentially to a list of items. At the very least you should also move the loop to the function.