I have a list and I want to replace all rows that are given by index pos with rows from different list. But the rows in different list are sequential while the rows in the original list that need to be replaced are not. So I have:
pos = {2, 3, 5};
tbl = Table[RandomReal[], {i, 6}, {j, 3}]
newR = {{1, 1, 0}, {0, 0, 1}, {1, 1, 1}};
(tbl[[pos[[#]]]] = newR[[#]]) & /@ Range[Length[pos]];
tbl
Is there a better way to achieve that (the 4th line)? I do not like the indexing tbl[[pos[[#]]]]
, so I was thinking whether it would be better with let's say tbl[[#]]=...
but then I do not know how to access newR
.