Extraction of elements of tuples

Bertaud picture Bertaud · Jan 27, 2011 · Viewed 29.6k times · Source

Given one list with one tuple:

[{4,1,144}]

How to extract the first element of the tuple inside the list:

element(1,lists:nth(1,L))

Do you have a simpler solution?

Answer

0xAX picture 0xAX · Jan 27, 2011

Try this:

1> A = [{3,1,1444}].
[{3,1,1444}]
2> [{X, _, _}] = A.
[{3,1,1444}]
3> X.
3
4>