[erlang-questions] Erlang again!

Boris Mühmer boris.muehmer@REDACTED
Thu Jul 22 18:55:13 CEST 2010


2010/7/22 Masklinn <masklinn@REDACTED>:
> What you want here is zip/2[0] or, even better, zipWith/3[1].

Well, I didn't know about zip or zipwith (still not inside the
library), so my solution was like this:

    sub(L2,L1) ->
        lists:reverse(sub(L2,L1,[])).

    sub([],[],List) ->
        List;
    sub([H2|T2],[H1|T1],List) ->
        sub(T2,T1,[(H2-H1)|List]).

Ok, this is much longer than with zip or zipwith, but somehow this was
much easier to "develop". Well, at the end of the documentation of
zipwith there is almost a solution to the problem, but I wouldn't have
found it, if zip or zipwith wasn't mentioned.

Is such a solution plain bad, or just a newbie mistake/error?


  - boris


More information about the erlang-questions mailing list