[erlang-questions] Mapping over 2+ lists/variables?

Sylvain Rousseau sylrouss@REDACTED
Wed Jul 23 19:20:49 CEST 2008


Hi,

You can do :
1> lists:zipwith(fun(X,Y) -> X+Y end, [1,2,3], [4,5,6]).
[5, 7, 9]

Does it help ?

Regards,
-- Sylvain

2008/7/23 Circular Function <circularfunc@REDACTED>:

> in python I can do:
> >>> map(lambda x,y:x+y,[1,2,3],[4,5,6])
> [5, 7, 9]
> >>>
>
> 38> lists:map(fun(X,Y) -> X+Y end,[1,2],[3,4]).
> ** exception error: undefined function lists:map/3
> 39>
>
> isnt there general map-function that map is derived from that I can use?
> what about listcomprehensions?
> 44> [X+Y || X,Y <- lists:seq(1,10),lists:seq(1,10)].
> * 1: variable 'X' is unbound
> 45>
>
> ------------------------------
> Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.
> Sök och jämför priser hos Kelkoo.<http://www.kelkoo.se/c-100015813-bredband.html?partnerId=96914325>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080723/40f4e2dc/attachment.htm>


More information about the erlang-questions mailing list