A few obfuscations via Listable
:
Block[{f, op},
SetAttributes[f, Listable];
op[x_] := {f[x, x]};
op[x_, y__] := Sequence[f[x, {x, y}], op[y]];
{op @@ list}
]
Block[{f},
SetAttributes[f, Listable];
f @@@ Table[{list[[i]], list[[i ;;]]}, {i, 4}]
]
Module[{op1, op2},
op1 = Function[{x, l}, f[x, l], Listable];
op2 = {op1[#, {##}], Sequence @@ If[{##2} =!= {}, op2[##2], {}]} &;
op2 @@ list
]
Update
The second method above is actually pretty good. The others aren't bad, but they are limited by $RecursionLimit
. This one is slightly faster:
f4 = Block[{f},
SetAttributes[f, Listable];
f[First[#], #] & /@ NestList[Rest, #, Length[#] - 1]
] &;
Timings
Adding to Mr.Wizard's comparison:
f1 = With[{n = Length[#]},
Table[f @@ #[[{i, j}]], {i, n}, {j, i, n}]] &;
f2 = MapIndexed[#[[#2[[1]] ;;]] &, Outer[f, #, #]] &;
f3[x_] := Thread@*f @@@ MapIndexed[{#, x[[First@#2 ;;]]} &, x];
f4 = Block[{f},
SetAttributes[f, Listable];
f[First[#], #] & /@ NestList[Rest, #, Length[#] - 1]
] &;
Needs["GeneralUtilities`"]
BenchmarkPlot[{f1, f2, f3, f4}, RandomInteger[999, #] &, 2^Range[12]]
