Aug-14-2018, 12:46 PM
Functional programming isn't about using lambdas. It is about writing programs with functions where something goes in and something goes out, but nothing else happens. The functions don't change anything (no side-effects), they just return a value. From that perspective, your first function is as functional as your second. However, the first one is really better from a functional standpoint. One idea of functional programming is to make things easier to read by not making your guess what changes are happening when you call a function. I think your use of lambdas in the second program makes it harder to read, even though it's not introducing side-effects. Lambdas are inline, single-use functions. If you are giving them names so you can use them across multiple lines, you should really just define a function.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures