-
-
Save edmz/e850f0e1b66614487177 to your computer and use it in GitHub Desktop.
Elixir version of[1] as revised by José Valim
1. http://devblog.avdi.org/2013/10/16/sorting-lines-in-5-languages/
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
# this version is by José Valim, my version was way more verbose and not quite as elixir-ish. | |
[input, output] = System.argv | |
File.write!(output, File.stream!(input) |> Enum.sort |> Enum.join("")) |
If i'm not mistaken, the reason for that is that when using pipelines, the resulting value of one method is what gets sent as the first paramater of the next call. File.write!() needs the path as the first parameter.
I'm pretty sure that could be taken care of using &
notation.
The |> Enum.join("")
part is unnecessary.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm curious if we could get the
File.write
into the pipeline as well somehow...