Aan de slagGa gratis aan de slag

Create, index, and slice a tuple

You've seen that one of the major differences between a tuple and other data structures, such as a vector is the immutability of the tuple. The creation of a tuple is very similar to that of a vector, and indexing and slicing will also be familiar to you, using the square bracket notation.

In this exercise, you will create, index, and slice a tuple that you will call emergency_information. This tuple should contain the three fields that you identified in the previous question as good data to store in a tuple.

To create a tuple, remember that you need to use parentheses () to contain the values you wish to store in the tuple.

To index and slice a tuple, use the square bracket [] notation after the name of the tuple. Indexing starts at 1 for the first element in Julia.

Deze oefening maakt deel uit van de cursus

Intermediate Julia

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create a tuple containing the emergency information
emergency_information = (____, ____, ____)
Code bewerken en uitvoeren