Why do arrows point towards the codomain in function diagrams? The definition of a function given in Kenneth Rosen's Discrete Math Book is

Let A and B be nonempty sets. A function from A to B is an assingment of exactly one element of B to each element of A. [Emphasis mine]

It seems the author wants us to think of the elements in the codomain being assigned to the elements in the domain, not the elements in the domain being assigned to the ones in the codomain. However, in this book and most others, functions are often illustrated with such diagrams:

If it is more useful to think of the elemnts in the codomain as assigned to the elements in the domain, is there a reason why the arrows are not pointing in the other direction?

There are several different metaphors for functions that seem to be colliding here.  For example:


*

*A function is a "machine" that takes an "input" and produces an "output"

*A function is a "mapping" that takes an "input" and sends it to an "output"

*A function is an "assignment" of a value to each element in the domain


The first two metaphors are most naturally thought of in terms of going from the element in the domain to the element in the codomain.  I agree with you that the third metaphor is most naturally thought of in the other direction.  Notice, though, how similar the following descriptions are, and how subtly the sense of "directionality" shifts:


*

*"An element of $B$ is assigned to each element of $A$"

*"To each element of $A$, we assign an element of $B$"

*"To each element of $A$ there corresponds an element of $B$"

*"Each element of $A$ is 'transformed' by the function into an element of $B$"

