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?
 A: 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$"

A: I would say that this is more about conventions than mathematics. As long as the mathematical meaning is clear, what is the big deal? 
For instance, in literature, the open interval $(a,b)$ can be also denoted as $]a,b[$. Arguing which notation is more reasonable is really not a mathematical question. 
A: The ideia is that each element of $A$ is associated to one, and only one, element of $B$.
If you didn't have "each", than you could have elements of $A$ that are not associated to anything in $B$. 
If you didn't had " one, and only one " you could have a multivalued relation, as if $f(a) $ could mean more than one element of $B$. The way the your text express it is just a rephrasing of this ideia. 
