If you are reading this, then most probably you already know quite well what functions are in programming. A function is quite a common and spread programming construct that is present in almost all programming languages.

Generally, a function is a block of code that takes some parameters from outside, executes some operations in which these parameters may be used, then it returns an output value. Actually, in many programming languages functions are allowed to not return something or to return multiple values, not only one. But these cases can be also be represented, for the sake of generality, as only one value. For the “no return” case we can use a special value to represent that (in Python that special value is None; whenever you don’t return something from a function it’s returned None). And for the case of more values, we can use a vector of multiple values as a single object.

For example, in Python a function definition looks like this:

def func_name(param1, param2, ...):

    ## do some stuff with input parameters
    return output_value

Now, the question I want to ask: Are these functions from programming true mathematical functions?

Well…, let’s first recall what a mathematical function is.

In mathematics, a function is just a mapping from a set A to a set B, in which any element from A has only one associated element in B.

#python #programming #function #mathematics #functional-programming

Are functions from programming really functions?
1.60 GEEK