I wanted to write myself a function that makes it possible to Insert several rows into one list.
matrix = Table[i*(j + 2), {i, 3}, {j, 3}];
vector1 = Range[10, 12];
vector2 = Range[20, 22];
This one worked perfectly fine:
Do[matrix = Insert[matrix, {vector1, vector2}[[i]], 1], {i, 2}];
Then I started straightforward with:
InsertRows[vectors_List, matrix_List, position_Integer] :=
Do[
matrix = Insert[matrix, vectors[[i]], position]
, {i, Length@vectors}]
This does not work. After little search I found that I have to force Do[] to return some value. But the same search also highlighted that it is not recommended to use Return[].
So here are my questions:
- How to define a function that can insert several rows. If there is an approach without a loop, I was happy to see it.
- How to properly define this function with the Do[] Loop.
InsertRows
when I copy and paste it into mathematica for vectors_list and matrix_list, "list" I get lower case l's $\endgroup$