In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. (Wikiped...
For further actions, you may consider blocking this person and/or reporting abuse
Separation of concern and DRY apply to programming in general. That is not specific to FP. I even hear more about them in OOP.
FP code being more memory efficient is something I've never heard of, but if you got a source feel free to link it or explain yourself. There might be cases or languages where this is true, but I feel like in the general case it is not.
And a little correction on pure functions. Map, filter, and reduce are only pure if the function you give to it is pure. There's nothing stopping you from doing side effects inside the passed function (although you should not). One common case I see is people using
map(print, mylist)to print a list, and then ignore the return value.I agree with @cappe987 .
Functional programming is about the way you design your software, and not much just with the use of these built-in functions.
Anyway, it is a good start. Though, keep in mind that for many examples the filter and map approaches are not the best in Python.
cheers,
@joaomcteixeira
I agree with you that Functional programming is more than the usage of pre-built functions in python.
I have demonstrated in a simple way to give a head-start to the people who are new to these concepts.
And filter and map may or may not be the best in python, but it gets our job done.
So it's all about trade-offs in programming.
Surely, I did not mean to disregard your post. I just wanted to expand @cappe987 comments further for the more advanced reader.
Cheers,
Ok
@cappe987
I agree that Separation of concern and DRY are generally practices we observe in programming.
But, I have specified them as the properties of Functional programming and I have not written that it is only applicable to FP, so don't get confused.
And you're right that we can also observe this in OOP.
To give you more insight, when I say separation of concern in functional programming I mean that we package our code into separate chunks so that everything is well organized in each part of our code and each part is organized in a way that makes sense on functionality. So when I say separation of concerns I mean each part concerned the self with one thing that it's good at.
Just like in OOP where we divide up attributes and methods,
functional programming has this idea as well of separating concerns where we also separate data and functions because they are two separate things.