+ 1

The difference between pure and impure function?

I am not really understand clearly about the difference between pure and impure function. Anyone can help me explain that? Thanks.

26th Feb 2017, 2:44 PM
AN TRAN TUAN
AN TRAN TUAN - avatar
2 odpowiedzi
+ 2
There are two aspects of purity. First you use no variable that you do not pass as an argument. Secondly, you do nothing but return a result, no printing to the screen, no setting of variables.
26th Feb 2017, 3:47 PM
1of3
1of3 - avatar
0
An impure function CHANGES the state of the program while a pure function always compute the same outcome when you give it the same arguments. A pure function never changes the state of the program
27th Feb 2017, 9:05 PM
Amaras A
Amaras A - avatar