Q: Simple list transform

Bruce Fitzsimons bruce@REDACTED
Thu May 17 23:59:12 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

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).

I know I could do it the traditional way and use two functions to iterate
the list, slicing off one item at a time and accumulating the result. Is
there an easier/nicer way?

Thanks in advance,

More information about the erlang-questions mailing list