Simple list transform

James Hague jamesh@REDACTED
Fri May 18 00:43:29 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}].

[{X,id}|| X <- [0,1,2,3,4]].

gives:

[{0,id},{1,id},{2,id},{3,id},{4,id}]

You can try this directly from the Erlang shell!

James



More information about the erlang-questions mailing list