Erlang -- tuples

Source: Internet
Author: User

(1) Operation of tuples in Erlang:

1. Concepts of tuples:

1. Fixed Number

2. Any types that Erlang can recognize

2. Create a tuples:

1. f = {A, XX, 123, {345, BB, CC, "XX "}}.

3. Extract tuples

1. Matching:

Eg:

F = {A, XX, 123 },

{A, XX, YY} = f. % the value of YY is 123.

2. Erlang: element (Pos, mytuple). Pos indicates the first element, starting from number 1.

4. Length of the tuples:

1. Erlang: length (mytuple ).

(2) Others:

1. because the number of tuples is fixed, no addition or deletion operations exist.

2. We recommend that you use an atom to represent the first item of the tuples:

Eg:

Len = {lenght, 10}. % indicates that the length is 10

Erlang -- tuples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.