Anonymous user
Repeat a string: Difference between revisions
→{{header|Pure}}: Pure implementation
(→{{header|C}}: C implementation) |
(→{{header|Pure}}: Pure implementation) |
||
Line 100:
=={{header|PowerBASIC}}==
<lang powerbasic>MSGBOX REPEAT$(5, "ha")</lang>
=={{header|Pure}}==
str_repeat is defined by pattern-matching: repeating any string 0 times results in the empty string; while
repeating it more than 0 times results in the concatenation of the string and (n-1) further repeats.
<lang pure>
> str_repeat 0 s = "";
> str_repeat n s = s + (str_repeat (n-1) s) if n>0;
> str_repeat 5 "ha";
"hahahahaha"
>
</lang>
=={{header|Python}}==
|