Group Data Objects into Tuples

Learn how to group data objects into pairs and tuples, as well as decompose them using pattern matching.

Primitive datatypes such as integers, floats, booleans, and strings are useful but often not sufficient. Yet, when modeling real-world phenomena, we often need to glue together data to form compound data. Consider the example of developing a software package for 2D graphics. To represent, say, a point we could use two separate float numbers denoting its x and y coordinate. But this could get messy because we would need to keep track of what x and y coordinates belong to what point. It’s much better to glue an x and y coordinate into a compound data object like a pair and treat the point as a single concept.

Get hands-on with 1400+ tech skills courses.