|
|
|
|
|
by nvln
1074 days ago
|
|
1. Immutability: Functions are expressions that return a singular value without mutating state. Most loops are not expressions and have some mutation happening. 2. Composition: If the loops don't mutate there are functional alternatives (map, reduce/fold, filter, etc) which are composable. 3. Abstraction: Loops are traversal instruments. Sophisticated functional languages / environments have some mechanism for generalizing traversal of any data structure into a higher order function or some form of reusable generalization. That said, I use a lot of loops in library code for performance and expose functional interfaces for consumers. |
|