It's worth looking at the other solutions in-thread. Key points:
- Use of higher-order operations, like filters and aggregations, to avoid loops.
- Passing around functions (the * and + side are the same, except for one operation) to avoid repeated code
This results in:
- Less code. Defects per KLOC tends to be pretty constant, so shorter / higher-level programs are typically less buggy.
- In particular, less repeated code. Cut-and-paste introduces a whole slew of potential defects.
- Less dependence on order-of-operations, which eliminates whole classes of errors, from off-by-ones to data structures in intermediate inconsistent states.