+ 2
Pure/impure Functions
Could someone please break down pure functions for me. I feel I do not quite get what the lesson was explaining in python tutorial. If you could provide me examples of pure and impure functions and why or what makes each one pure or impure.
1 ответ
+ 2
A pure function uses only its arguments to produce the output:
def pure_add(a, b):
return a + b
An impure function uses information not passed to it in arguments:
B = 5
def impure_add(a):
return a + B