Jump to content

Repeat a string: Difference between revisions

→‎{{header|REXX}}: added the '''changestr''' bif. -- ~~~~
(→‎{{header|REXX}}: added the '''changestr''' bif. -- ~~~~)
Line 876:
=={{header|REXX}}==
Since the REXX language only supports the "character" type, it's not surprising that there are so many ways to skin a cat.
<br><br>Some older REXXes don't have the '''changestr''' bif, so one is included here.
<lang REXX>/*REXX program to show various ways to repeat a string (or repeat a single char).*/
 
Line 992 ⟶ 993:
y="any more examples and the angry townfolk will burn the castle."
parse value y||y||y||y||y with z
 
</lang>
exit
/*───────────────────────────CHANGESTR subroutine───────────────────────*/
changestr: procedure; parse arg o,h,n; r=; w=length(o); if w==0 then return n||h
do forever; parse var h y (o) _ +(w) h; if _=='' then return r||y; r=r||y||n; end</lang>
 
=={{header|Ruby}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.