# How to sum a number over an element of each pair of a list? [duplicate]

Here's a following list:

L={{a,b},{c,d},{e,f}}. I want a function such that it sums a number over the first element of each pair. For instance, take the number 1. I need:

L={{a+1,b}, {c+1,d}, {e+1,f}}. Which function does this?

Thanks!

• I'm sure this is a dupe, but: TranslationTransform[{1, 0}][{{a,b},{c,d},{e,f}}] Mar 12, 2018 at 16:13
• No function necessary: L[[All, 1]] = L[[All, 1]] + 1.
– JimB
Mar 12, 2018 at 16:28
• L + ConstantArray[{1, 0}, Length[L]] Mar 12, 2018 at 18:09

Clear[a, b, c, d, e, f]
lst = {{a, b}, {c, d}, {e, f}}
"TranslationTransform (JM's soln):"
TranslationTransform[{1, 0}]@lst
"ReplaceAll:"
lst /. {{x_, y_} -> {x + 1, y}}
"The ever reliable Map:"
{1 + First@#, Last@#} & /@ lst
"ReplacePart:"
ReplacePart[lst, xy : {_, 1} :> Extract[lst, xy] + 1]
"Part (JimB's answer); changes lst!:"
lst[[All, 1]] += 1  (* this is not the answer *)
lst  (* this is *)

l = {{a,b},{c,d},{e,f}}
Map[{#[]+1,#[]}&,l]