List of symbols wherein position encoded by number to string
list = {{a, 6}, {z, 1}, {g, 2}, {y, 12}};
#2 -> ToString[#] & @@@ list // Append[_ -> "-"] // SparseArray // StringJoin
"zg---a-----y"
One more alternative, using StringReplacePart[]
:
l = {{"a", 6}, {"z", 1}, {"g", 2}, {"y", 12}};
str = StringJoin[ConstantArray["-", Max[l[[All, -1]]]]];
Fold[StringReplacePart[#1, Sequence @@ #2] &, str,
MapAt[ConstantArray[#, 2] &, l, {All, -1}]]
Pre-processing:
str = {{a, 6}, {z, 1}, {g, 2}, {y, 12}};
len = Max@Last@Transpose@str
out = StringRepeat["-", len]
String manipulations:
repl = {ToString /@ #1, Transpose@{#2, #2}} & @@ (Transpose@str)
StringReplacePart[out, #1, #2] & @@ repl
"zg---a-----y"