GIML: Tutorial Three: Hints

In creating recursive functions of this sort you must give two equations. The first is the base equation; for this we specify the value of the function at some fixed value of the parameter, often 0 or 1. The left hand side of the equation has the actual value 0 or 1 in place of the parameter, the right hand side of the = has the output required of the function at that value.
The recursive equation typically tells the system how to construct the n case from the n-1 case. On the left of the recursive equation we have n as the parameter, on the right hand side the function will appear within some expression however the call will be made to the function at n-1 rather than n. fun sumto 0 = 0 | sumto n = n + sumto(n-1); fun listfrom 0 = [] | listfrom n = n::listfrom(n-1); fun strcopy(s, 0) = "" | strcopy(s, n) = s ^ strcopy(s,n-1); Now go back and try the rest of the problems before getting the rest of the answers from here.