Pascal-Chapter Tuples

Chapter 8 : Tuples

Hey captain, I’m lieutenant Washburne, the pilot of this piece of junk. Just let me know the coordinates of where you want to go and I’ll try my best to bring us there in one piece…

Tuples gather multiple values in a specific order which can be retrieved with their indexes.

To define a tuple, use parenthesis and the * operator :

type name is (string * string)

And to define a value of this type :

const my_name : name = (“Jack”, “Oneill”)


You can access each component of a tuple by their position :

const my_name_first_name : string = my_name.0
const my_name_last_name : string = my_name.1


You can modify a component of tuple by assigning values as if it were a variable :

my_name.1 := “Carter”

Your mission

1- Create a tuple type coordinates representing a 3D location.

2- Define earth_coordinates at coordinates 2,7,1.

3- Let’s say you made a mistake in the definition. Change the last parameter of earth_coordinates to 5.


Type your solution above and validate your answer