Types of Function

The fight between Purity(Pure) and Impurity(Non-Pure)

Pure function:
These are those wonderful creature that obey your order and create NO side effects. They only do what they are intended to do.
def abs(x):
if x>0 return x else return -x

All this function does is for some input value generates an output value. Thats it! No other crap!

On the other hands the NAUGHTY child of the programming family. Non Pure functions, In addition to returning the value that they were meant to return, they generate some side effect, make some changes to the environment! Idiots!
print(1) :
print function return a value None in python but displays some content on the console(Side Effect)

Try in Python 3.* : print(print(“Side”), print(“Effect!”))

To-DO :
Add advantages of using pure functions!

 
4
Kudos
 
4
Kudos

Now read this

Nothing kills a bad product faster than good marketing – Well, So when is it appropriate to spend on marketing?

Every product would essentially have fans (hopefully many), critics (as small as possible) and few fence sitters. It is important to understand the potential of your product and you can do this by defining a coefficient using your fans... Continue →