My goal is to add an index to all elements of a list in the form {"a", "b", "c", ... }
, so it becomes {"N1 a", "N2 b", "N3 c" ... }
, where the elements of the list are strings.
My current method is (sequence is a pre-defined list):
sequence =
Table[
"N" <> ToString[i] <> " " <> ToString[sequence[[i]]],
{i, 1, Length[sequence]}];
I wonder if there's a more clever approach to this, since using Table
seems like an overkill.
I can append a string to every element using:
sequence =
Replace[sequence, x_?StringQ :> "Test " <> ToString[x], All];
But here I don't know how to include the position/index of the elements, since they're not unique and I cannot use Position
to determine their index.