Jump to content

Phrase reversals: Difference between revisions

→‎{{header|Julia}}: A new entry for Julia
(→‎{{header|Julia}}: A new entry for Julia)
Line 513:
2. each word reversed: attesor edoc esarhp lasrever
3. word-order reversed: reversal phrase code rosetta
 
=={{header|Julia}}==
<lang Julia>
s = "rosetta code phrase reversal"
 
println("The original phrase.")
println(" ", s)
 
println("Reverse the string.")
t = reverse(s)
println(" ", t)
 
println("Reverse each individual word in the string.")
t = join(map(reverse, split(s, " ")), " ")
println(" ", t)
 
println("Reverse the order of each word of the phrase.")
t = join(reverse(split(s, " ")), " ")
println(" ", t)
</lang>
 
{{out}}
<pre>
The original phrase.
rosetta code phrase reversal
Reverse the string.
lasrever esarhp edoc attesor
Reverse each individual word in the string.
attesor edoc esarhp lasrever
Reverse the order of each word of the phrase.
reversal phrase code rosetta
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.