Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Created September 28, 2014 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hepplerj/c626e0e26d37c08363c6 to your computer and use it in GitHub Desktop.
Save hepplerj/c626e0e26d37c08363c6 to your computer and use it in GitHub Desktop.
# Ruby example
reverse_lines = File.open("poem.txt").readlines.reverse
# p reverse_lines
reverse_lines.each do |line|
words = line.split.reverse
puts words.join(" ")
end
O CAPTAIN! my Captain! our fearful trip is done;
The ship has weather'd every rack, the prize we sought is won;
The port is near, the bells I hear, the people all exulting,
While follow eyes the steady keel, the vessel grim and daring:
But O heart! heart! heart!
O the bleeding drops of red,
Where on the deck my Captain lies,
Fallen cold and dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment