Reverse words in a string: Difference between revisions

no edit summary
m (→‎{{header|Tailspin}}: syntax update)
No edit summary
Line 2,175:
END ReverseWords.
</lang>
 
=={{header|Nanoquery}}==
<lang nanoquery>def reverse_words(string)
tokens = split(string, " ")
if len(tokens) = 0
return ""
end
 
ret_str = ""
for i in range(len(tokens) - 1, 0)
ret_str += tokens[i] + " "
end
return ret_str.substring(0, len(ret_str) - 1)
end
 
data = "---------- Ice and Fire ------------\n" +\
" \n" +\
"fire, in end will world the say Some\n" +\
"ice. in say Some \n" +\
"desire of tasted I've what From \n" +\
"fire. favor who those with hold I \n" +\
" \n" +\
"... elided paragraph last ... \n" +\
"Frost Robert -----------------------\n"
 
for line in split(data, "\n")
println reverse_words(line)
end</lang>
{{out}}
<pre>------------ Fire and Ice ----------
 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
 
... last paragraph elided ...
----------------------- Robert Frost</pre>
 
=={{header|Nial}}==
Anonymous user