Created
April 6, 2017 13:42
-
-
Save Preen/d1c2f52dc493598b718b8d5b5edc7fe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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