Anonymous user
Reverse words in a string: Difference between revisions
→{{header|R}}
Line 2,513:
<lang R>
whack <- function(s) {
paste( rev( unlist(strsplit(s, " ")
poem <- unlist( strsplit(
'------------ Eldorado ----------
Line 2,527:
Eldorado!" for seek you "If
Poe Edgar -----------------------', "\n")
for (line in poem) cat( whack(line), "\n" )
Line 2,552:
<lang R>
> `{` <- function(s) rev(unlist(strsplit(s, " ")
> {"one two three four five"}
[1] "five" "four" "three" "two" "one"
|