anchor.diff:  -behavior(gen_event).
   
   %% API
  --export([add_handler/0, delete_handler/0]).
  +% -export([add_handler/0, delete_handler/0]).
   
   %% gen_event callbacks
  --export([init/1, handle_event/2, handle_call/2, handle_info/2, 
  -         terminate/2, code_change/3]).
  +% -export([init/1, handle_event/2, handle_call/2, handle_info/2, 
  +%          terminate/2, code_change/3]).
  +
  +-compile(export_all).
   
   %%%============================================================================
   %%% API
  
positive.code: %%%============================================================================
  %%% Internal functions
  %%%============================================================================
  handle_fac_command(From, To, Arg) ->
      case try_parse_int(Arg) of
          {ok, Int} -> 
              F = fac(Int),
              nani_bot:say(To, [From, ": ", integer_to_list(F)]);
          {error, _} -> 
              nani_bot:say(To, [From, ": ", Arg, " is not a valid integer."])
      end.
  
  handle_fmt_command(From, To, Fmt, Arg) ->
      case try_parse_int(Arg) of
          {ok, Int} ->
              case try_fmt_arg(Fmt, Int) of
                  {ok, Str} ->
                      nani_bot:say(To, [From, ": ", Str]);
                  {error, _} ->
                      nani_bot:say(To, [From, ": ", Fmt, " is not a valid format string."])
              end;
          {error, _} ->
              nani_bot:say(To, [From, ": ", Arg, " is not a valid integer."])
      end.
  
  handle_fread_command(From, To, Fmt, Arg) ->
      case try_fread_arg(Fmt, Arg) of
          {ok, Val} ->
              nani_bot:say(To, [From, ": ", integer_to_list(Val)]);
          {error, _} ->
              nani_bot:say(To, [From, ": ", " either the format string or argument doesn't make sense."])
      end.
  
  try_fread_arg(Fmt, Arg) ->
  
negative.code:     end.
  
  fac(0) -> 1;
  fac(N) -> N * fac(N - 1).
  
  parse_cmd(Cmd) ->
     Str = binary_to_list(Cmd),
     lists:map(fun string:to_lower/1, string:tokens(Str, " ")).