You can do it with either a Julia comprehension or a generator.
julia> VERSION
v"1.0.0"
julia> s = "123abc"
"123abc"
# n is number of times to repeat each character.
julia> n = 3
3
# Using a Julia comprehension with [...]
julia> join([c^n for c in s])
"111222333aaabbbccc"
# Using a Julia generator without the [...]
julia> join(c^n for c in s)
"111222333aaabbbccc"
For small strings there should be little practical difference in speed.
Edit
TL;DR: In general, the generator is somewhat faster than the comprehension. However, see case 3 for the opposite. The memory estimates were very similar.
@rickhg12hs has suggested it would be nice to have benchmarks.
Using the great BenchmarkTools package, the results are below.
n = the number of times to repeat each character
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" in each case
In each case, the comprehension median time, C, is listed first, vs the generator median time, G, second. The times were rounded as seemed appropriate and the original figures are below the numbered summaries. Smaller, of course, is better.
The memory estimates were not very different.
1. n = 26, C=3.8 vs. G=2.8 μs, G faster
julia> using BenchmarkTools
julia> n = 26;
julia> @benchmark join([c^n for c in s])
BenchmarkTools.Trial:
memory estimate: 3.55 KiB
allocs estimate: 39
--------------
minimum time: 3.688 μs (0.00% GC)
median time: 3.849 μs (0.00% GC)
mean time: 4.956 μs (16.27% GC)
maximum time: 5.211 ms (99.85% GC)
--------------
samples: 10000
evals/sample: 8
julia> @benchmark join(c^n for c in s)
BenchmarkTools.Trial:
memory estimate: 3.19 KiB
allocs estimate: 36
--------------
minimum time: 2.661 μs (0.00% GC)
median time: 2.756 μs (0.00% GC)
mean time: 3.622 μs (19.94% GC)
maximum time: 4.638 ms (99.89% GC)
--------------
samples: 10000
evals/sample: 9
2. n = 260, C=10.7 vs. G=8.1 μs, G faster
julia> n = 260;
julia> @benchmark join([c^n for c in s])
BenchmarkTools.Trial:
memory estimate: 19.23 KiB
allocs estimate: 39
--------------
minimum time: 8.125 μs (0.00% GC)
median time: 10.691 μs (0.00% GC)
mean time: 18.559 μs (35.36% GC)
maximum time: 43.930 ms (99.92% GC)
--------------
samples: 10000
evals/sample: 1
julia> @benchmark join(c^n for c in s)
BenchmarkTools.Trial:
memory estimate: 18.88 KiB
allocs estimate: 36
--------------
minimum time: 7.270 μs (0.00% GC)
median time: 8.126 μs (0.00% GC)
mean time: 10.872 μs (18.04% GC)
maximum time: 10.592 ms (99.87% GC)
--------------
samples: 10000
evals/sample: 4
3. n = 2,600, C=62.3 vs. G=63.7 μs, C faster
julia> n = 2600;
julia> @benchmark join([c^n for c in s])
BenchmarkTools.Trial:
memory estimate: 150.16 KiB
allocs estimate: 39
--------------
minimum time: 51.746 μs (0.00% GC)
median time: 63.293 μs (0.00% GC)
mean time: 77.315 μs (2.79% GC)
maximum time: 3.721 ms (96.85% GC)
--------------
samples: 10000
evals/sample: 1
julia> @benchmark join(c^n for c in s)
BenchmarkTools.Trial:
memory estimate: 149.80 KiB
allocs estimate: 36
--------------
minimum time: 47.897 μs (0.00% GC)
median time: 63.720 μs (0.00% GC)
mean time: 88.716 μs (17.58% GC)
maximum time: 42.457 ms (99.83% GC)
--------------
samples: 10000
evals/sample: 1
4. n = 26,000, C=667 vs. G=516 μs, G faster
julia> n = 26000;
julia> @benchmark join([c^n for c in s])
BenchmarkTools.Trial:
memory estimate: 1.44 MiB
allocs estimate: 39
--------------
minimum time: 457.589 μs (0.00% GC)
median time: 666.710 μs (0.00% GC)
mean time: 729.592 μs (10.91% GC)
maximum time: 42.673 ms (98.76% GC)
--------------
samples: 6659
evals/sample: 1
julia> @benchmark join(c^n for c in s)
BenchmarkTools.Trial:
memory estimate: 1.44 MiB
allocs estimate: 36
--------------
minimum time: 475.977 μs (0.00% GC)
median time: 516.176 μs (0.00% GC)
mean time: 659.001 μs (10.36% GC)
maximum time: 42.268 ms (98.41% GC)
--------------
samples: 7548
evals/sample: 1