[erlang-questions] Erlang shows its slow face!

黃耀賢 (Yau-Hsien Huang) <>
Mon Nov 15 04:41:03 CET 2010


I appreciate that this answer is very insight.

Some discussions before showed that rewriting and rewriting the Erlang code
may beat the speed of the C# program. Some did specific programming
techniques
on aspects of this problem. However, it ought to be that keeping C# program
written in operational semantics the same as the Erlang one. Thus, your
answer is a better one, simple and fair.


On Mon, Nov 15, 2010 at 9:06 AM, Richard O'Keefe <> wrote:

>
> On 13/11/2010, at 8:37 PM, Gilberto Carmenate García wrote:
>
> > Hi all!
> > I have been doing tests to Erlang I found this funny stuff that makes
> > Pythagorean Triplets
> >
> > pythag(N) ->
> >    [ {A,B,C} ||
> >        A <- lists:seq(1,N),
> >        B <- lists:seq(1,N),
> >        C <- lists:seq(1,N),
> >        A+B+C =< N,
> >        A*A+B*B =:= C*C].
>
> That's not as efficient as it could be.
>
>        C <- lists:seq(1, N),
>         A <- lists:seq(1, N-C-1),
>        B <- lists:seq(1, N-C-A),
>
> does a factor of 6 or better fewer iterations (tested up to N = 500).
>
>
-- 

Best Regards.

--- Y-H. H.


More information about the erlang-questions mailing list