Created
April 6, 2016 21:43
-
-
Save wende/9ae902104016472d6b5a7919abb182a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Queue do | |
@moduledoc """ | |
Elixir wrapper around Erlang's 'queue' module, following the convention of pipe operator | |
""" | |
@functions :queue.module_info(:exports) | |
Enum.map @functions, fn | |
{:module_info, _} -> 0 | |
{name, 0} -> def unquote(name)(), do: apply(:queue, unquote(name), []) | |
{name, 1} -> def unquote(name)(x), do: apply(:queue, unquote(name), [x]) | |
{name, 2} -> def unquote(name)(x,y), do: apply(:queue, unquote(name), [y, x]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment