Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

m
(add OCaml)
m (→‎{{header|Wren}}: Minor tidy)
 
(2 intermediate revisions by 2 users not shown)
Line 629:
C:\My Projects\BGI>
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ sharefile drop
[] swap
[ carriage over find split
dup $ "" != while
behead drop
unrot nested swap join
swap again ]
drop nested swap join
witheach [ echo$ cr ] ] is task ( $ --> )
 
$ "rosetta/input.txt" task</syntaxhighlight>
 
{{out}}
 
<pre> --- Will Rodgers
until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of
</pre>
 
=={{header|R}}==
<syntaxhighlight lang="rsplus">text <- scan("Rodgers.txt", character(), sep = "\n")
Line 797 ⟶ 821:
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">puts File.readlines("diplomacy.txt").reverse</syntaxhighlight>
{{out}}
<pre> --- Will Rodgers
 
until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of
</pre>
=={{header|sed}}==
<syntaxhighlight lang="sed">1!G
Line 811 ⟶ 844:
 
</pre>
 
 
=={{header|UNIX Shell}}==
Line 827 ⟶ 859:
=={{header|Wren}}==
{{libheader|Wren-ioutil}}
<syntaxhighlight lang="ecmascriptwren">import "./ioutil" for File, FileUtil
 
var fileName1 = "rodgers.txt"
9,476

edits