Repeat a string: Difference between revisions

→‎{{header|D}}: add example of repeating a single character
(→‎{{header|J}}: extend for additional task)
(→‎{{header|D}}: add example of repeating a single character)
Line 75:
 
=={{header|D}}==
Repeating a string:
<lang d>import std.stdio;
import std.string;
Line 81 ⟶ 82:
{
writefln(repeat("ha", 5));
}</lang>
Repeating a character with vector operations:
<lang d>import std.stdio;
 
void main() {
char[]str; // create the dynamic array
str.length = 5; // set the length
str[]='*'; // set all characters in the string to '*'
writefln(str);
}</lang>
 
Anonymous user