+ 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.

26th Jan 2017, 9:29 PM
Damien Bertrand
Damien Bertrand - avatar
1 Antwort
+ 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
30th Jan 2017, 2:31 AM
Igor B
Igor B - avatar