3 ms·
Now your code performs worse. Benchmark both. You'll find that the reduce is much slower than the for loop. This commonly doesn't matter when the body of the
by compressedgas 3y ago
Now your code performs worse. Benchmark both.
You'll find that the reduce is much slower than the for loop.
This commonly doesn't matter when the body of the loop is something with an IO delay however.
Also except for embedded applications or kernel programming, stack space or variables are so plentiful.
You are better off using more variables.