Jump to content

Phrase reversals: Difference between revisions

m
→‎{{header|Phix}}: changed to match output of other entries, syntax coloured
m (→‎{{header|Phix}}: changed to match output of other entries, syntax coloured)
Line 1,808:
 
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
I have assumed step 2 should be applied to the result of step 1, and step 3 applied to the result of step 2.<br>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Obviously I'm right and everyone else is wrong!
<langspan Phixstyle="color: #008080;">constant</span> <span style="color: #000000;">test</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"rosetta code phrase reversal"</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">fmt</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"""
?reverse(test)
The original phrase as given: %s
sequence words = split(reverse(test))
1. Reverse the entire phrase: %s
for i=1 to length(words) do
2. Reverse words, same order: %s
words[i] = reverse(words[i])
3. Reverse order, same words: %s
end for
"""</span>
?join(words)
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">test</span><span style="color: #0000FF;">,</span>
?join(reverse(words))</lang>
<span style="color: #7060A8;">reverse</span><span style="color: #0000FF;">(</span><span style="color: #000000;">test</span><span style="color: #0000FF;">),</span>
<span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #000000;">test</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">reverse</span><span style="color: #0000FF;">)),</span>
<span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">reverse</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #000000;">test</span><span style="color: #0000FF;">)))})</span>
<!--</lang>-->
{{out}}
<pre>
"The original phrase as given: rosetta code phrase reversal"
"1. Reverse the entire phrase: lasrever esarhp edoc attesor"
"reversal phrase code rosetta"
2. Reverse words, same order: attesor edoc esarhp lasrever
"rosetta code phrase reversal"
"3. Reverse order, same words: reversal phrase code rosetta"
</pre>
 
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.