User blog comment:Lord Aspect/SATCLN II/@comment-32783837-20180319184628/@comment-32783837-20180320183917

Try something like:

F(a) = [whatever]

f(a,1,b) = F(a)

f(a,b) = f(F(a),b-1)

f(a,b,1) = f(a,b)

f(a,b,c) = f(a,f(a,b-1,c),c-1)