Skip to content

Instantly share code, notes, and snippets.

@wende
Created April 6, 2016 21:43
Show Gist options
  • Save wende/9ae902104016472d6b5a7919abb182a7 to your computer and use it in GitHub Desktop.
Save wende/9ae902104016472d6b5a7919abb182a7 to your computer and use it in GitHub Desktop.
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