Brief Notes
Noteworthy links, summaries and concise prose on stuff.

Elixir development

All about developing with the Elixir Programming Language.

Notes

Counting the number of lines in a file:

"./a_very_big_file.csv" |> File.stream! |> Enum.count

# => 859369 -> took about 3 seconds to run inside an iex session on my MacBook Air

Sort a list in ascending order:

Enum.sort(["b", "aaa", "cc", "*", "."])

# => ["*", ".", "aaa", "b", "cc"]

Sort a list in descending order:

Enum.sort(["b", "aaa", "cc", "*", "."], &(&1 > &2))

# => ["cc", "b", "aaa", ".", "*"]

Sort a list of strings by the length of each string, in ascending order:

Enum.sort_by(["b", "a", "aaa", "cc"], &String.length/1)

# => ["b", "a", "cc", "aaa"]

Sort a list of strings by the length of each string, in descending order:

Enum.sort_by(["b", "a", "aaa", "cc"], &String.length/1, &(&1 > &2))

# => ["aaa", "cc", "a", "b"]

References