Trying to understand how many functions there are from A to B. I'm trying to understand why there are $B^A$ functions from $A$ to $B$. If $A=${$a,b$} and $B=${$1,2,3$} then the functions from $A$ to $B$ are $f(a)=1$, $f(b)=1$, $f(a)=2$, $f(b)=2$, $f(a)=3$, $f(b)=3$. If this is correct then there are only 6 functions. 
Am I going about things incorrectly?
 A: The only restriction for $f$ to be a function is that there must be exactly $1$ output for each input.  What $a$ can map to is completely independent of what $b$ can map to.  Hence, $a$ can map to $1$, $2$, or $3$, and likewise for $b$.  
$\Longrightarrow$ there are $3 \times 3 = 9$ possibilities.
Note that this is the same as the age-old combinatorics question "How many ways are there to distribute $r$ distinguishable balls into $n$ distinguishable boxes?".  The question changes slightly if you add certain restrictions like injectivity or surjectivity.  This link might be of interest to you.
A: Hint: The function does not have to be injective. For each element in your domain, you have $|B|$ choices for it to map to.
A: Fix an element in  $A$, see that it can be mapped to any element in $B$. So you have |$B$| possibilities for each element of $A$. now count the total possibilities as the element varies in $A$ also.
A: The restriction on function $f:A\rightarrow B$ is that every element in $A$ should be mapped to some element in $B$ and every element should have a unique mapping i.e. no element in $A$ should be mapped to $2$ different elements in $B$. However, there is no such restriction on $B$.
So for every element in B, you have to choose $0$ to $n(A)$ elements. So you have $n(A)$ for each element in $B$. That gives us $n(A)$ choices for $n(B)$ elements i.e. a total of $n(B)^{n(A)}$ choices
