I have two lists, where the number of elements of list 1 = number of sublists of list 2:
list1 = {a,b}; list2 = {{f,g,h,i},{j,k,l,m}} I would like to add elements of list1 to the last elements of list2, so I did
list3 = MapThread[Append,{list2,list1}]; list3 = list3 /. {x1_,x2_,x3_,x4_,x5_} -> {x1,x2,x3,x4+x5} It works but I suspect there is a more efficient way with, perhaps, MapAt or some combination of functions that I can't figure out. How would you do it? Thanks in advance.