Jump to content

Reverse words in a string: Difference between revisions

Line 2,547:
----------------------- Edgar Poe
</pre>
 
As a dangerous stunt, let's redefine "<tt>{</tt>".
(Everything that happens in R is a function-call.)
 
<lang R>
> `{` <- function(s) rev(strsplit(s, " ")[[1]])
> {"one two three four five"}
[1] "five" "four" "three" "two" "one"
</lang>
 
You had better restart your REPL after trying this.
 
=={{header|Racket}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.