Simple list transform

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Simple list transform

James Hague-3
> 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