मराठी

Why strlen is called pure function?

Advertisements

प्रश्न

Why strlen is called pure function?

टीपा लिहा
Advertisements

उत्तर

strlen (s) is called each time and strlen needs to iterate over the whole of ‘s’. If the compiler is smart enough to work out that strlen is a pure function and that ‘s’ is not updated in the lbop, then it can remove the redundant extra calls to strlen and make the loop execute only one time. This function reads external memory but does not change it, and the value returned derives from the external memory accessed.

shaalaa.com
Pure Functions
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1: Function - Evaluation [पृष्ठ ९]
Advertisements
Share
Notifications



      Forgot password?
Use app×