[erlang-questions] Mapping over 2+ lists/variables?
Lev Walkin
vlm@REDACTED
Wed Jul 23 19:14:12 CEST 2008
Circular Function wrote:
>
> 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>
Try opening a manual page for lists module
erl -man lists
and look for zip, zipwith, zipwith3
> 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>
[X + Y || X <- lists:seq(1,10), Y <- lists:seq(1,10)].
--
vlm
More information about the erlang-questions
mailing list