All the examples from the source above:
"In simple terms, functional programming is all about building functions for immutable variables.
In contrast, object-oriented programming is about having a relatively fixed set of functions, and you're primarily modifying or adding new variables.
Because of its nature, functional programming is great for in-demand tasks such as data analysis and machine learning."
In simple words:
a function of x = it transforms some input x into some output y
But x could be multidimensional, but one object. And y could be like x...
So we could imagine a long deep pipe of multidimentional transformations which are built from a little" Lego bricks" that can reach the sky... with a little help of chain elements like this snippet of Python code:
def square(x):
return x*x
Is FP stateless?
Is OOP stateful?
"A function with clearly declared in- and outputs is one without side effects. And a function without side effects is a pure function.
A very simple definition of functional programming is this: writing a program only in pure functions.
Pure functions never modify variables, but only create new ones as an output. "
No comments:
Post a Comment