Skip to main content
added 309 characters in body
Source Link
user1066
  • 23.9k
  • 3
  • 43
  • 65
BlockMap[Flatten,Riffle[list, x[[;;Length@list]]],2] (* {{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *) 

In addition, a variation on the neat answer given by xzczd

MapThread[Replace,{list,{a_, b_} :> {a, b, x[[#]]}&/@Range@Length@list}] (*{{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *) 
BlockMap[Flatten,Riffle[list, x[[;;Length@list]]],2] (* {{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *) 
BlockMap[Flatten,Riffle[list, x[[;;Length@list]]],2] (* {{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *) 

In addition, a variation on the neat answer given by xzczd

MapThread[Replace,{list,{a_, b_} :> {a, b, x[[#]]}&/@Range@Length@list}] (*{{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *) 
Source Link
user1066
  • 23.9k
  • 3
  • 43
  • 65

BlockMap[Flatten,Riffle[list, x[[;;Length@list]]],2] (* {{1,2,x1},{5,2,x2},{9,3,x3},{6,5,x4}} *)