# Adding Elements to a List of Lists [duplicate]

I'm trying to do the following: Given a function f[x,y], I want to turn the list {{x1,y1},{x2,y2},...,{xn,yn}} into {{x1,y1,f[x1,y1]},{x2,y2,f[x2,y2]},...,{xn,yn,f[xn,yn]}}.

In other words, I want to replace each 2-tuple in the original list of lists with a 3-tuple, where the 3rd element is a function evaluated using the 2-tuple. For example, if f[x,y] is x+y, then I'd want {{1,2},{5,6}} to be turned into {{1,2,3},{5,6,11}}.

I've seen syntax for many similar tasks, but not one quite like this. I would tremendously appreciate any help -- I've been stumped on this one for a while!

• Hello, wellcome to Mathematica.SE. Try {##, f[##]}& @@@ list. And help me find a duplicate in old posts, there is one for sure. – Kuba Mar 7 '14 at 9:16
• Thanks for the super speedy help -- I'll try to track down a duplicate. I really appreciate it! – JWG Mar 7 '14 at 9:19
• You're wonderful -- thank you so much again :) – JWG Mar 7 '14 at 9:33