Function: Difference between revisions

From Objective Mathematics
Jump to navigation Jump to search
(Created page with "A '''function''' is a machine that takes in one thing and spits out another. [TODO gross definition] == Examples == The following lines of C++ code are a function string reverseString(const string &s) { string returnStr = ""; for (int i = s.size() - 1; i >= 0; --i) { returnStr.append(s[I]); } return returnStr; }")
 
Line 2: Line 2:


== Examples ==
== Examples ==
The following lines of C++ code are a function
The following table is a function:
{| class="wikitable"
|+f(x)
|x
|(0,0)
|(1,0)
|(0,1)
|(1,1)
|-
|f(x)
|0
|1
|1
|0
|}
That table describes the input and output of an XOR gate,
[TODO]
 
which is also a function.
 
The following lines of C++ code are a function:
  string reverseString(const string &s) {  
  string reverseString(const string &s) {  
   string returnStr = "";  
   string returnStr = "";  

Revision as of 03:26, 20 January 2024

A function is a machine that takes in one thing and spits out another. [TODO gross definition]

Examples

The following table is a function:

f(x)
x (0,0) (1,0) (0,1) (1,1)
f(x) 0 1 1 0

That table describes the input and output of an XOR gate, [TODO]

which is also a function.

The following lines of C++ code are a function:

string reverseString(const string &s) { 
  string returnStr = ""; 
  for (int i = s.size() - 1; i >= 0; --i) { 
    returnStr.append(s[I]);
  }
  return returnStr;
}