Reverse words in a string: Difference between revisions

m
(Added solution for Action!)
Line 1,675:
 
The verb phrase <code>( [: ; @ |. [: < ;. 1 ' ' , ])</code> reverses words in a string. The rest of the implementation has to do with defining the block of text we are working on, and applying this verb phrase to each line of that text.
 
Another approach:
 
<lang J>echo ;:inv@|.@cut;._2 {{)n
---------- Ice and Fire ------------
fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I
... elided paragraph last ...
Frost Robert -----------------------
}}</lang>
 
produces:
 
<pre>
------------ Fire and Ice ----------
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
... last paragraph elided ...
----------------------- Robert Frost
</pre>
 
=={{header|Java}}==
6,951

edits