Consider two tables
tab1 = RandomReal[{0, 1}, {5, 4}]
tab2 = RandomReal[{0, 1}, {10, 4}]
How to quickly make a table where the ith row of tab1
follows by 2(i-1)+1th and 2*ith rows of tab2
, and for each corresponding 3 rows, one adds the row {tab1[[i]][[1]],0,0,0}
? The ugly way to do this is
Flatten[Table[{{tab1[[i]][[1]],0,0,0},tab1[[i]],tab2[[2*(i-1)+1]],tab2[[2*i]]},{i,1,Length[tab1],1}],1]
Table
and a symbolici
? $\endgroup$Flatten[Riffle[{{#[[1]],0,0,0},#}&/@tab1,Partition[tab2,2]],1]
pass your ugly test? I think it produces exactly the same output as your code. Test this carefully before you trust it. $\endgroup$