Skip to content

Instantly share code, notes, and snippets.

@fenollp
Created March 2, 2014 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fenollp/9315903 to your computer and use it in GitHub Desktop.
Save fenollp/9315903 to your computer and use it in GitHub Desktop.
-module(thear).
-export([simplify/1]).
-spec simplify (E) -> E when E::term().
simplify (E) ->
S = fun
({add,E1,{num,0}}) ->
S(E1);
({add,{num,0},E2}) ->
S(E2);
end,
case S(E) of
E -> E;
R -> simplify(R)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment