lambda x: x+1
If you only program with lambda's like these, your program is functional. def dosomething(x):
y = x + 3 # y is a global variable
return x + 1
As soon as you have a function like this, your program is no longer 100% functional.The dosomething function modified `state` when it changed a global variable. Another function that modifies state is "print()". Generally any function that returns nothing is almost certainly going to modify state outside of it. (Otherwise what is the function for?)
State is memory that is not `local` to the function itself.
def dosomething(x):
y = x + 3 # y is a local variable
return x + 1
The dosomething function here is functional, because the only `state` it modified was local to the function.There you have it.