3 ms·
A for loop could mean anything, and not necessarily what the author intended. https://en.wikipedia.org/wiki/Rule_of_least_power https://en.wikipedia.org/wiki/Ru
by erik_seaberg 7y ago
A for loop could mean anything, and not necessarily what the author intended. https://en.wikipedia.org/wiki/Rule_of_least_power https://en.wikipedia.org/wiki/Rule_of_least_power leads to list.filter(p) always calls p O(n) and returns a list of the same type with some or all of the same elements. list.map(f) always calls f O(n) times and returns a list of the same length. p and f can be reused and only depend on a single element. A good platform will inline list.filter(p).head into machine code that exits a loop early, that you don't have to write or review.