Primitive recursive function: Difference between revisions

Content deleted Content added
Definition: separate source code of cases ; function composition as a special case
Definition: uniquely use <math> in this section ; rm  
Line 30:
f(S(y),x_1,\ldots,x_k) &= h(y,f(y,x_1,\ldots,x_k),x_1,\ldots,x_k).\end{align}</math>
''Interpretation:''
The function&nbsp;'' <math>f''</math> acts as a [[for loop|for-loop]] from <math>0</math> up to the value of its first argument. The rest of the arguments for&nbsp;'' <math>f''</math>, denoted here with ''x''<sub>1</submath>x_1,&nbsp;...\ldots,&nbsp;''x''<sub>''k''x_k</submath>, are a set of initial conditions for the for-loop which may be used by it during calculations but which are immutable by it. The functions ''<math>g''</math> and ''<math>h''</math> on the right-hand side of the equations that define ''<math>f''</math> represent the body of the loop, which performs calculations. The function&nbsp;'' <math>g''</math> is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by&nbsp;'' <math>h''</math>. The first parameter of&nbsp;'' <math>h''</math> is fed the "current" value of the for-loop's index. The second parameter of&nbsp;'' <math>h''</math> is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for&nbsp;'' <math>h''</math> are those immutable initial conditions for the for-loop mentioned earlier. They may be used by&nbsp;'' <math>h''</math> to perform calculations but they will not themselves be altered by&nbsp;'' <math>h''</math>.
}}