prod(f,itr) short-circuit if
No. Currently it just uses
*. You can try it with
@time prod(0:1_000_000), and see that it takes significantly longer than
But I’m not sure if it should? There would be some overhead to checking for
iszero, and it wouldn’t work for iterables of types where
iszero can’t be sensibly defined, like a string.
Yet a version of
mapreduce which checks the accumulator for a specific value and returns early upon encountering it could be useful.