Phrase reversals: Difference between revisions

m
→‎version 2: changed comments, used a template for the output section.
No edit summary
m (→‎version 2: changed comments, used a template for the output section.)
Line 1,775:
 
===version 2===
<lang rexx>/*REXX program reverses words and/or also letters in a string in various (several) ways. */
parse arg $ /*obtain optional arguments from the CL*/
if $='' then $= "rosetta code phrase reversal" /*Not specified? Then use the default.*/
L=; W= /*initialize two REXX variables to null*/
do j=1 for words($); _= word($, j) /*extract each word in the $ string. */
L= L reverse(_); W= _ W /*reverse the letters; in areverse wordwprds. */
W=_ W /*reverse the words in the string. */
end /*j*/
/*display some results to the terminal.*/
say ' the original phrase used: ' $
say ' original phrase reversed: ' reverse($)
say ' reversed individual words: ' strip(L)
say ' reversed words in phrases: ' W /*stick a fork in it, we're all done. */</lang>
'''{{out|output'''|text=&nbsp; when using the default input string:}}
<pre>
the original phrase used: rosetta code phrase reversal