Skip to content

Instantly share code, notes, and snippets.

lauromoura / memoize.ex
Last active May 3, 2016 — forked from brunoro/memoize.ex
Memoization using a `defmem` macro and a gen_server.
View memoize.ex
defmodule Memoize do
alias Memoize.ResultTable
defmacro defmem(header, do: body) do
{ name, _meta, vars } = header
quote do
def unquote(header) do
case ResultTable.get(unquote(name), unquote(vars)) do
{ :hit, result } ->