Javatpoint Logo
Javatpoint Logo

Functional Programming-Records

Records are known as the data structure to store the fixed number of elements. Records are similar, just like the structure in the C language. At the compilation time, expressions of records can translate into the tuple expression.

Creation of Record

The 'record' keyword is used to create the record with the name of the record and its field.

The syntax of the record is shown as below:

Syntax used to insert the value in the record is as shown below:

Program to create the records in Erlang

Below example shows how we can create the record of the student contains two fields like stuname and stuid.

Program to create the record in C++.

Below example shows how we can create the record in C++, C++ is known as the object-oriented programming.

Program to access the values of the record in Erlang

The below program shows how we can access the values of the record in Erlang. Erlang is known as functional programming.

The output of the above program will look like, as shown below:

5 
"Sachin"

Program to access the values of the record in C++

The below program shows how we can access the values of the record in C++ are as:

The output of the above code will look like, as shown below:

5 
Sachin

We can update the record's values after changing the value of that particular field and then assigned the record to the new variable name.

Now we will take two examples to understand how we can do this by using the object-oriented and the functional programming language.

Program to update the values of the record in the Erlang

The below program shows how we can update the values of the record by using the Erlang:

The output of the above code will look like, as shown below:

5
"Jonny" 

Program to update the values of the record in C++

The below program shows how we can update the record values in C++.

The output of the above program will look like, as shown below:

Jonny 
5 
value after updating 
Jonny 
10 





Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA