[erlang-questions] Erlang shows its slow face!

Anthony Shipman <>
Sat Nov 13 09:10:28 CET 2010


On Sat, 13 Nov 2010 06:37:08 pm Gilberto Carmenate García wrote:
> So my question is, there are any way to do that even more fast, why 3
> nestes fors structs in C# are more effients that lists:foldr or
> lists:foreach in Erlang.

It goes 10 times faster when compiled to native code.
The following takes 0.8s on my machine.

pythag2(N) ->
    L = lists:seq(1,N),

    [ {A,B,C} ||
        A <- L, 
        B <- L,
        C <- L,
        A+B+C =< N,
        A*A+B*B =:= C*C].

-- 
Anthony Shipman                    Mamas don't let your babies 
                   grow up to be outsourced.


More information about the erlang-questions mailing list