English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Differentiate pure and impure functions. - Computer Science

Advertisements
Advertisements

Question

Differentiate pure and impure functions.

Distinguish Between

Solution

Pure Function:

  1. The return value of the pure functions solely depends on its arguments passed.
  2. If you call the pure functions with the same set of arguments, you will always get the same return values.
  3. They do not have any side effects.
  4. They do not modify the arguments which are passed to them.

Impure Function:

  1. The return value of the impure functions does not solely depend on its arguments passed.
  2. If you call the impure functions with the same set of arguments, you might get different return values. For example, random( ), Date( ).
  3. They have side effects.
  4. They may modify the arguments which are passed to them.
shaalaa.com
Pure Functions
  Is there an error in this question or solution?
Chapter 1: Function - Evaluation [Page 9]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 1 Function
Evaluation | Q 4. | Page 9
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×