
Data Structure

This illustrates a data structure, a means of storing data within a program.

You may see other such structures in the Data Structures category.


Task

Create a compound data type:

  Point(x,y) 



A compound data type is one that holds multiple independent values.



Related task

   Enumeration


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


 
-module(records_test).
-compile(export_all).
 
-record(point,{x,y}).
 
test() ->
    P1 = #point{x=1.0,y=2.0}, % creates a new point record
    io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
    P2 = P1#point{x=3.0}, % creates a new point record with x set to 3.0, y is copied from P1
    io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
 