© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
T. MailundIntroduction to Computational Thinkinghttps://doi.org/10.1007/978-1-4842-7077-6_6

6. Functions

Thomas Mailund1  
Aarhus N, Denmark

So far, we have implemented algorithms where we have a reference to our input before we run our computations and where we print the algorithm’s output when we are done. Our algorithm is the code between the input and the output. But what happens if, for example, we need to sort more than one list?

With the approach we have seen so far, we would need to copy the entire code for each time we need to run an algorithm. This will give us many copies of the same code, so what if there is an error in the code? We would need ...

Get Introduction to Computational Thinking: Problem Solving, Algorithms, Data Structures, and More now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.