|
|
|
|
|
by yyyk
2014 days ago
|
|
I usually like the FP style better, however that's not the best example. You're using a for loop rather than a foreach loop - admittedly C doesn't have foreach, but most other imperative languages have some variation of it, even BCPL had it. foreach/map have the advantage of working based on array size information, while for needs to be told.
That gives the FP version an unrelated advantage. Switch to foreach, and none of the 'classes of problems' you mention apply to the imperative version of the code. |
|