Why doesn't this work:
mergeList[a_, b_] := (
list = a;
Insert[list, 98, 3];
Do[
Do[
(
If[
b[[f]] < list[[s]],
(Insert[list, b[[f]], s]; Break[])
]
),
{s, Length[list]}
],
{f, Length[b]}
];
list
)
It doesn't give an error, it just outputs the original value of list = a
For example:
mergeList[{1, 2, 3, 4}, {2, 3, 4, 5}]
outputs {1, 2, 3, 4}, and I don't know why.
list = Insert[list, b[[f]], s]– ciao Apr 09 '14 at 21:10Set,AppendToandPrependTo,IncrementandAddTo. You can think of it as working on a copy. If you want the result to overwrite the original you have to useSet. – Sjoerd C. de Vries Apr 09 '14 at 21:24