Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Functional Programming: Side Effects

Tags:

Most tutorials/articles/books talk about side effects when presenting functional programming. Take this Python code:

def isPrime(n):
    k = 2
    while k < n:
        if n % k == 0:
            return False
        k += 1
    return True

The text says that the above function has local side effects, and I don't understand that. I see that the variable "k" is changing, I don't understand what bad comes out of it.

Can someone please give a clear example of bad side effect, and how it is avoided by functional programming?