# Mapping a function f[xi_,xj_] over a list {x1, …, xn} with the i < j restriction

I am often facing the situation where I have a list $$\{...x_k...\}$$ and where I want to compute:

$$\{...f[x_i,x_j]...\}\text{ with }\ i

Unfortunately, I have not been able to find an elegant solution for this problem. What I'm doing right now seems horrible to me (indirections etc...):

n = 4;
x = Table[RandomReal[], n]


{0.547984, 0.601967, 0.000917483, 0.738287}

Map[f[Apply[Sequence, x[[#]]]] &,
Flatten[Table[{i, j}, {i, 1, n}, {j, i + 1, n}], 1]]


{f[0.547984, 0.601967], f[0.547984, 0.000917483], f[0.547984, 0.738287], f[0.601967, 0.000917483], f[0.601967, 0.738287], f[0.000917483, 0.738287]}

(in real situation f is defined f[xi_,xj_]:= xi-xj for instance)

Question: what is a better (builtin?) solution?

Subsets[f @@ x, {2}]

f @@@ Subsets[x, {2}]