For a function f[n, a], where a is a list and n is a whole number, what is the correct syntax for
f[n - 5, f[n - 4, f[n - 3, f[n - 2, f[n - 1, f[n, a]]]]]]
?
All I want to do is
fg[n_, w_] := f1@ff[n, w]
fg[n - 2, fg[n - 1, fg[n, list]]]
as shown above, which works, but I am having to manually write out n-3,n-2,n-1,...
Have tried
fg[n_][w_] := f1@ff[n, w]
NestList[fg[n], list, 3]
but doesn't quite work. I think it needs a #-1 in there somewhere, that is applied to the n, but not sure on syntax.
Answer
Last @ Nest[{ #[[1]] - 1, f1[ ff[ #[[1]], #[[2]] ] ] } &,
{n, list},
3]
f1[ff[-2 + n, f1[ff[-1 + n, f1[ff[n, list]]]]]]
Comments
Post a Comment