# Changing one argument of a multivariable function at each step of Fold

I have a function, call it F[a_List,b_,c_,d_] which takes in 4 arguments. Now I want to compose this function with itself, where the number of compositions I want to perform is given by the length of a. For that I thought I could use Fold, but I am not sure how to set it up. There is something else. At each step of Fold, one of my arguments changes, namely achanges and also at each step the output of applying F replaces b. For instance, say a is a list of length 4. I would like to get the final output of:

F[a[[4]],F[a[[3]],F[a[[2]],F[a[[1]],b,c,d],c,d],c,d],c,d]

Can I do that using Fold? Or is there some other, hopefully more efficient way?

• @MichaelE2 I believe I do not, b is being successively replaced by the output of applying F as we go through the composition. Does that make sense? – amator2357 Jun 6 at 13:12
• Ah, my bad. I was on a phone and had trouble matching all the brackets by eye. – Michael E2 Jun 6 at 17:21

You can use Fold as follows:
Fold[F[#2, #, c, d] &, b, Array[a, 4]]