Phrase reversals: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: changed to match output of other entries, syntax coloured) |
|||
Line 1,808: | Line 1,808: | ||
=={{header|Phix}}== |
=={{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! |
|||
< |
<span style="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}} |
{{out}} |
||
<pre> |
<pre> |
||
⚫ | |||
1. Reverse the entire phrase: lasrever esarhp edoc attesor |
|||
⚫ | |||
2. Reverse words, same order: attesor edoc esarhp lasrever |
|||
⚫ | |||
⚫ | |||
</pre> |
</pre> |
||