Function: Difference between revisions

From Objective Mathematics
Jump to navigation Jump to search
Line 17: Line 17:
|0
|0
|}
|}
That table describes the input and output of an XOR gate,
That table describes the input and output of an XOR gate. A XOR gate (another example of a function) can also be seen in the figure.  
[TODO]
[[File:617645 orig.png|thumb|Redstone XOR gate in Minecraft]]
 
which is also a function.  
 
The following lines of C++ code are a function:
The following lines of C++ code are a function:
  string reverseString(const string &s) {  
  string reverseString(const string &s) {  

Revision as of 03:43, 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. A XOR gate (another example of a function) can also be seen in the figure.

Redstone XOR gate in Minecraft

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;
}