Anonymous user
Reverse words in a string: Difference between revisions
→{{header|Python}}
Line 2,508:
----------------------- Robert Frost</lang>
=={{header|R}}==
<lang R>
whack <- function(s) {
paste( rev(strsplit(s, " ")[[1]]), collapse=' ' ) }
poem <- strsplit(
'------------ Eldorado ----------
... here omitted lines ...
Mountains the "Over
Moon, the Of
Shadow, the of Valley the Down
ride," boldly Ride,
replied,--- shade The
Eldorado!" for seek you "If
Poe Edgar -----------------------', "\n")[[1]]
for (line in poem) cat( whack(line), "\n" )
</lang>
{{out}}
<pre>
---------- Eldorado ------------
... lines omitted here ...
"Over the Mountains
Of the Moon,
Down the Valley of the Shadow,
Ride, boldly ride,"
The shade replied,---
"If you seek for Eldorado!"
----------------------- Edgar Poe
</pre>
=={{header|Racket}}==
|