[erlang-questions] Erlang arithmetics

Max Lapshin <>
Sat Oct 30 23:29:13 CEST 2010


Can this trivial code be optimized with HiPE?


-module(a).

-export([z/0]).

z() ->
  T1 = erlang:now(),
  V = z(100000, 0),
  T2 = erlang:now(),
  put(v, V),
  io:format("S: ~p~n", [timer:now_diff(T2, T1)]),
  ok.


z(0, S) ->
  S;

z(N, S) when is_number(N) andalso is_number(S) ->
  z(N - 1, S*2 + 3).


More information about the erlang-questions mailing list