def iter[A](f: A => A, n: Int): A => A = {
if (n == 1) {
f
} else {
f(iter(f,n-1))
}
}
I want to make a function iter that makes function composition of f, for example:
iter(f,1) = f
iter(f,2) = f(f)
But I can't find a way how to pass type A into function f recursively, how can I solve this problem?