Anonymous user
Reverse words in a string: Difference between revisions
→{{header|Elixir}}: here document
No edit summary |
(→{{header|Elixir}}: here document) |
||
Line 527:
=={{header|Elixir}}==
<lang elixir>defmodule RC do
def reverse_words(txt) do
txt |> String.split("\n") # split lines
Line 537 ⟶ 536:
|> Enum.join("\n") # rejoin lines
end
end</lang>
Usage:
<lang elixir>txt = """
▲ "---------- 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" <>
... elided paragraph last ...
▲ " \n" <>
"""
▲ "Frost Robert -----------------------"
IO.puts RC.reverse_words(txt)</lang>
=={{header|Gema}}==
|