I am on a problem that asked to write a function that applies a function to an Integer and calculate the answer. Here is the problem:
Declare the type and define a function that takes a function (say f) and an integer (say n) and returns f 0 + f 1 + f 2 + … + f n. For example, fun sq 5 would returns 55 which is 0+1+4+9+16+25 (“sq” means “square”).
Does anyone know how to do that? I would very much appreciate it.