Exit[]

partial

partial[paolo][f_,v_,1]:=f[v,#1,#2]&
partial[paolo][f_,v_,2]:=f[#1,v,#2]&
partial[paolo][f_,v_,3]:=f[#1,#2,v]&

testFun[a_,b_,c_]:=a^b+c

#1^#2+#3&

Function[{x,y,z},x^y+z]

test[1]=
{partial[paolo][testFun,Pi,1][a,b],
partial[paolo][testFun,Pi,2][a,b],
partial[paolo][testFun,Pi,3][a,b]}

test[2]=
{partial[paolo][#1^#2+#3&,Pi,1][a,b],
partial[paolo][#1^#2+#3&,Pi,2][a,b],
partial[paolo][#1^#2+#3&,Pi,3][a,b]}

test[3]=
{partial[paolo][Function[{x,y,z},x^y+z],Pi,1][a,b],
partial[paolo][Function[{x,y,z},x^y+z],Pi,2][a,b],
partial[paolo][Function[{x,y,z},x^y+z],Pi,3][a,b]}

SameQ@@Array[test,3]

total

total[f_,v_,p_]:=Insert[{##},v,p]&

Insert[list,elem,n]

testFun2[args__]:=
MapIndexed[g,{args}]

total[testFun2,Pi,3][a,b,c,d,e,f]

total[f_,v_,p_]:=f@@Insert[{##},v,p]&

total[testFun2,Pi,3][a,b,c,d,e,f]

myFun=Function[{a,b,c,d,e,f,g},
a+b/c+d^e+Sin[f]/Cos[g]];

total[myFun,Pi,3][x,y,z,w,h,k]

nested

nested[f_,k_]:=Nest[f,#,k]&

nested[Sin,4][t]

Sin[Sin[Sin[Sin[3.]]]]-nested[Sin,4][3.]

nested[#^2+#+1&,4][t]

nested[#^2+#+1&,4][2]

pure[f_,1]:=f

pure[f_,0]:=#&

pure[f_,k_]:=
pure[f,k-1][f[#]]&

pure[Sin,4][3.]

pure[Sin,4][3.]-nested[Sin,4][3.]

pure[#^2+#+1&,4][2]

pure2[f_,0]:=#&

pure2[f_,k_]:=
f[pure2[f,k-1][#]]&

pure2[Sin,4][3.]

input=
MapIndexed[
{#1,#2[[1]]}&,RandomSample[Range[10]]
]

cycles[p_]:=
ReplaceRepeated[
ReplaceRepeated[
p,
{l___,{h__,t_},m___,{t_,b_},r___}->{l,{h,t,b},m,r}
],
{l___,{a_,m___,a_},r___}->
{l,{a,m},r}
]

cycles[input]

Map[
Max[
Map[
Length,
cycles[#]
]
]&,

Table[
MapIndexed[
{#1,#2[[1]]}&,RandomSample[Range[40]]
],
{5000}]
]//Tally//ListPlot

Count

Flatten[
Map[
Map[
Length,
cycles[#]
]&,

Table[
MapIndexed[
{#1,#2[[1]]}&,RandomSample[Range[40]]
],
{5000}]
]
]//Tally//ListPlot

1/6

Permutations[Range[6]]//Length

Map[
Max[
Map[
Length,
cycles[#]
]
]&,

MapIndexed[
{#1,#2[[2]]}&,Permutations[Range[9]],{2}
]
]//Tally

60480/9!