How many distinct functions can be defined from set A to B? In my discrete mathematics class our notes say that between set $A$ (having $6$ elements) and set $B$ (having $8$ elements), there are $8^6$ distinct functions that can be formed, in other words: $|B|^{|A|}$ distinct functions. But no explanation is offered and I can't seem to figure out why this is true. Can anyone elaborate?

Let's say for concreteness that $A$ is the set $\{p,q,r,s,t,u\}$, and $B$ is a set with $8$ elements distinct from those of $A$. Let's try to define a function $f:A\to B$.
What is $f(p)$?  It could be any element of $B$, so we have 8 choices.
What is $f(q)$?  It could be any element of $B$, so we have 8 choices.
...
What is $f(u)$?  It could be any element of $B$, so we have 8 choices.
So there are $8\cdot8\cdot8\cdot8\cdot8\cdot8 = 8^6$ ways to choose values for $f$, and each possible set of choices defines a different function $f$.  So that's how many functions there are.
