3.9 Tuple

A tuple is a compound data type with a fixed number of terms:

  1. {Term1,...,TermN}

Each term Term in the tuple is called an element. The number of elements is said to be the size of the tuple.

There exists a number of BIFs to manipulate tuples.

Examples:

  1. 1> P = {adam,24,{july,29}}.
  2. {adam,24,{july,29}}
  3. 2> element(1,P).
  4. adam
  5. 3> element(3,P).
  6. {july,29}
  7. 4> P2 = setelement(2,P,25).
  8. {adam,25,{july,29}}
  9. 5> tuple_size(P).
  10. 3
  11. 6> tuple_size({}).
  12. 0