Skip to content

Instantly share code, notes, and snippets.

@Preen
Created April 6, 2017 13:42
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 Preen/d1c2f52dc493598b718b8d5b5edc7fe1 to your computer and use it in GitHub Desktop.
Save Preen/d1c2f52dc493598b718b8d5b5edc7fe1 to your computer and use it in GitHub Desktop.
defmodule Read do
def read do
case File.read("sample.txt") do
{ :ok, body } ->
String.split(body, "\n")
|> Stream.filter(&String.starts_with?(&1, "d"))
|> Enum.sort(&(byte_size(&1) >= byte_size(&2) ))
|> Stream.each(&IO.puts(String.capitalize(&1)))
|> Stream.run
{ :error, reason } ->
IO.puts reason
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment