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

Edwin Fine <>
Wed Jul 23 19:25:35 CEST 2008


2> [X + Y || {X, Y} <- lists:zip([1,2,3], [4,5,6])].
[5,7,9]


2008/7/23 Circular Function <>:

> 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
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
The great enemy of the truth is very often not the lie -- deliberate,
contrived and dishonest, but the myth, persistent, persuasive, and
unrealistic. Belief in myths allows the comfort of opinion without the
discomfort of thought.
John F. Kennedy 35th president of US 1961-1963 (1917 - 1963)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080723/aa14171d/attachment.html>


More information about the erlang-questions mailing list