First, I think your approach will suffer from late closure binding, as function in lambda will only take the last value of function at the end of the iteration. Secondly, composed will only call itself recursively in the end also due to the first reason; composed - the lambda - calls the last value of composed - itself!

One possible fix is to bind composed and function to the lambda at each iteration: