Q: Simple list transform

Kent Boortz kent@REDACTED
Fri May 18 00:19:08 CEST 2001

> Its the simpliest things that give me trouble in Erlang. I am trying to work
> out how I can transform the list [0,1,2,3,4] into the list
> [{0,Y},{1,Y},{2,Y},{3,Y},{4,Y}].
> I've looked at map, but the function only takes one argument (an array
> element) and I can't see a way to wedge another one in. I think I'm correct
> in assuming that unless I pass a variable as an argument to a fun it doesn't
> have it in its scope, so I can't do this:
> Y = "really cool id",
> IdList = [0,1,2,3,4] ,
> map(fun(Num) -> {Num, Y} end,IdList).

This code works fine. Look at the scoping rules section 2.4 in



More information about the erlang-questions mailing list