|
|
|
|
|
by WorldMaker
1342 days ago
|
|
I don't think Functional Programmers have a fear of for-loops, I think they love for-loops, they just prefer to define them "steps first". A silly cross-paradigm way to look at it is that a lot of functional programming is about "dependency injecting the for-loop" and "inversion of control of the for-loop". For similar reasons to dependency injection in OOP, functional programming wants to focus on the more interesting to the program abstractions up front and leave the final "for-loop wiring" to libraries or the language itself. The for-loops don't go away, they are still there as necessary wiring. The functional programmer just wants to "dependency inject" all the interesting piece-at-a-time steps inside that for-loop rather than worry about the entire final wired loop body. Just like dependency injection in OO is supposed to make it possible to deal with a class at a time without needing as much of the entire class diagram in your head all once. Also, just like dependency injection: it's designed so that you have a lot smaller, easier to test pieces that make up the whole. |
|