RosettaCodeData/Task/Reverse-words-in-a-string/R/reverse-words-in-a-string-1.r
2018-06-22 20:57:24 +00:00

18 lines
394 B
R

whack <- function(s) {
paste( rev( unlist(strsplit(s, " "))), collapse=' ' ) }
poem <- unlist( 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"))
for (line in poem) cat( whack(line), "\n" )