-module(macro2).
-export([f/2,fx/1]).
-record(pair,{left,right}).
-define( tuple_to_pair_rec, 
         (fun({E1,E2}) -> #pair{left=E1,right=E2};
             (X) -> X end)).

f(A,B) -> 
    if (A==0) or (B==0) ->
            throw(zero_is_an_illegal_argument);
        true ->
            macro2t:f_({abs(A),abs(B)}) end.


fx({A,0}) -> 0;
fx(R) -> 
    fx(fun(#pair{left=X,right=Y})-> {Y, X rem Y} end
         (?tuple_to_pair_rec(R))).

