Concept

How do functions provide a well-defined answer?

Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk / Chapter 1

"One of the things that makes functions useful is that we can ask “which element of Y goes with X?” and we will always get back a well-defined answer. We can’t really do that with relations in general, because the answer might be “none” or “several.” With F, I can ask, “which drink does Hermione map to?” and the answer is “Mt. Dew.” In symbols, we write this as follows: F(Hermione) = Mt. Dew. This will look familiar to computer programmers, since it resembles a function call. In fact, it is a function call. “Functions” in languages like C++ and Java were in fact named after this discrete math notion. If you know anything about programming, you know that in a program I can “call the F() function” and “pass it the argument ‘Hermione’” and “get the return value ‘Mt. Dew.’” I never have to worry about getting more than one value back, or getting none at all."

Related Ideas

How do functions provide a well-defined answer? | Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk | Bifalgorithm | Bifalgorithm