I have a midterm coming up next week and I was just going over the sml notes provided in class. I came across a currying example and I was not sure exactly how it worked.
It is a simple function which computes the power of a number. Here is the function definition:
fun pow 0 n = 1 | pow k n = n*pow(k-1)n
I'm not sure how this function works when we pass it the following arguments:
val x = pow 2 2
This is the way I see it:
=2*pow(1)2
=2*(2*pow(0)2)2
=2*(2*(1)2)2)
The result we should be getting is four but I don't see how we get this result from the steps I have carried out above.
Help Please. Thank-You.