Bifalgorithm post · Brisk · Chapter 1

How do functions provide a well-defined answer?

How do functions provide a well-defined answer? (Brisk · Chapter 1) — "One of the things that makes functions useful is that we can ask “which element of Y goe…

Ideas in this flowchart

  • Functions associate each input with exactly one well-defined output.
  • For a function, asking which element of Y goes with X always produces an answer.
  • A general relation may associate an input with no elements or with several elements.
  • The function F maps Hermione to the drink Mt. Dew.
  • The mapping is written symbolically as F(Hermione) = Mt. Dew.
  • This notation resembles a function call in programming languages.
  • A program calls F() and passes Hermione as its argument.
  • The function call returns Mt. Dew as its return value.
  • A function call never returns more than one value or no value at all.
Feed/

How do functions provide a well-defined answer?

Channel

Brisk

1 page

"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."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.