Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elixir version of[1] as revised by José Valim 1. http://devblog.avdi.org/2013/10/16/sorting-lines-in-5-languages/
# 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(""))
@avdi

This comment has been minimized.

Show comment
Hide comment
@avdi

avdi Oct 16, 2013

I'm curious if we could get the File.write into the pipeline as well somehow...

avdi commented Oct 16, 2013

I'm curious if we could get the File.write into the pipeline as well somehow...

@edmz

This comment has been minimized.

Show comment
Hide comment
@edmz

edmz Oct 16, 2013

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.

Owner

edmz commented Oct 16, 2013

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.

@avdi

This comment has been minimized.

Show comment
Hide comment
@avdi

avdi Oct 16, 2013

I'm pretty sure that could be taken care of using & notation.

avdi commented Oct 16, 2013

I'm pretty sure that could be taken care of using & notation.

@alco

This comment has been minimized.

Show comment
Hide comment
@alco

alco May 1, 2016

The |> Enum.join("") part is unnecessary.

alco commented May 1, 2016

The |> Enum.join("") part is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment