can any one give the explanation and differences between pure and impure functional programming in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can any one give the explanation and differences between pure and impure functional programming in python

differences between pure and impure functional programming in python

9th Jun 2019, 7:12 AM
Raj kumar Darshanala
1 Answer
+ 1
Pure: a = 20 def f9(x): return x*2 a = f(4) Impure: a = 20 def f9(x): a = x * 2 f9(4) In both variable a value was changed from 20 to 8 Now look about the Impure version. Think about if the f9 definition of impure function was moved to the Moon. How would you then know while reading the code that a's value is changed when f9 is called? That's one example, where using impure function reduces the readability.
9th Jun 2019, 9:48 PM
Seb TheS
Seb TheS - avatar