[erlang-questions] per function/process locals

James Hague <>
Mon Apr 30 17:38:20 CEST 2007


A slight correction to the code sample:

    ~LOCAL{Ints, Floats, Atoms}

    count(L) -> count (L, ~{Ints = 0 :: Floats = 0 :: Atoms = 0}).
    count([H|T], ~LOCAL) ->
       if
          is_integer(H) -> count(T, ~{Ints = Ints+1});
          is_float(H)  -> count(T, ~{Floats = Floats+1});
          is_atom(H) -> count(T, ~{Atoms = Atoms+1});
          true -> count(T, ~{}) <---- THIS LINE WAS MISSING
       end;
    count([], ~LOCAL) ->
       {Ints, Floats, Atoms}.

    ~LOCAL{}



More information about the erlang-questions mailing list