Pure and impure functions?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Pure and impure functions??

What is really the difference between them?What a pure function?

25th Mar 2018, 10:13 AM
HBhZ_C
HBhZ_C - avatar
1 Answer
+ 1
A pure-function takes its input arguments to produce an output without affecting any external state like, for example, global variables. Moreover, a pure-function does not use external states like, for example, random.randint (1,100) which is external to the function and its input values. In the other side are impure-functions which affect external states or produce outputs using them.
25th Mar 2018, 11:26 PM
Billy Edson Burgoa Rosso
Billy Edson Burgoa Rosso - avatar