Reshaping nested list
list = {{x1, y1, f1}, {x2, y2, f2}};
Transpose[{Drop[list, 0, -1], list[[All, -1]]}]
(* {{{x1, y1}, f1}, {{x2, y2}, f2}} *)
I think my vote is this so far, but I bet there's even cleaner/more clever ways to do this:
data = {{x1, y1, f1}, {x2, y2, f2}}
Replace[data, {x_, y_, f_} :> {{x, y}, f}, {1}]
I like the Apply solution just fine too:
Apply[{{#1, #2}, #3} &, {{x1, y1, f1}, {x2, y2, f2}}, {1}]
For larger data they perform similarly, with Replace winning slightly:
In[53]:= data=(ToExpression/@{"x"<>#,"y"<>#,"f"<>#})&/@(ToString[#]&/@Range[1000000]);
Apply[{{#1,#2},#3}&,data,{1}]//RepeatedTiming//First
Replace[data,{x_,y_,f_}:>{{x,y},f},{1}]//RepeatedTiming//First
Out[54]= 0.825
Out[55]= 0.740
This is much better than the most naive approach:
In[57]:= ({{#[[1]], #[[2]]}, #[[3]]} & /@ data) //
RepeatedTiming // First
Out[57]= 1.859
The solution from @Oppenede is similar in timing to Apply
In[77]:= Transpose[{Drop[data, 0, -1], data[[All, -1]]}] // RepeatedTiming // First
Out[77]= 0.836
Use a rule and replacement:
{{x1, y1, f1}, {x2, y2, f2}} /. {x_, y_, f_} -> {{x, y}, f}
(* {{{x1,y1},f1},{{x2,y2},f2}} *)