Repeat a string: Difference between revisions
Content added Content deleted
(→{{header|C}}: C implementation) |
(→{{header|Pure}}: Pure implementation) |
||
Line 100: | Line 100: | ||
=={{header|PowerBASIC}}== |
=={{header|PowerBASIC}}== |
||
<lang powerbasic>MSGBOX REPEAT$(5, "ha")</lang> |
<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}}== |
=={{header|Python}}== |