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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With