In Kanamori's book on large cardinals (second edition), on page 300, he is proving 22.4 Proposition (d), where the proposition says that if $U$ is an $\omega_1$-complete ultrafilter over a set $S$, and $j$ is the corresponding ultrapower embedding from $V$ to $M$, then $U$ is not in $M$. In the proof he argues that every well-ordering of $S$ is in $M$, and then says that so it is straightforward to see that the set of all functions from $S$ to $|S|^+$ is in $M$.
I'm sure I'm missing something simple, but I don't know why the straightforward part follows. Any help would be appreciated!
Let $\kappa=\vert S\vert^+$. First, let's make the following apparently-weaker observation:
This is immediate: such an $f$ can be "nicely definably coded" by the well-ordering $\triangleleft_f$ of $S$ given by $a\triangleleft_fb\iff f(a)<f(b)$, and we already know that all well-orderings of $S$ are in $M$.
Now we just have to argue that every function $S\rightarrow\kappa$ can be "nicely definably coded" by an injective range-closed-downwards function; this gives that every function from $S$ to $\kappa$ is in $M$, whence we have $({}^S\kappa)^M={}^S\kappa$ (using Kanamori's notation for function sets) and we're done. This coding isn't hard, but it is a little tedious; let me know if you'd like more details, and I'll add them.
EDIT: As requested, here are some details! For simplicity, it will help to assume that $S$ is itself an infinite set of ordinals $<\kappa$.
First, coding non-injective functions by injective functions is easy: we just use a pairing operation on ordinals. Given $f:S\rightarrow\kappa$, the function $$\hat{f}:S\rightarrow\kappa: s\mapsto \langle s, f(s)\rangle$$ is injective and "equi-definable" with $f$.
Now to take care of downward-closure, we can just "break apart" $S$ into two pieces $S_0\sqcup S_1$; $S_0$ has the same cardinality as $S$ itself (via some nicely-definable bijection), and $S_1$ has the same cardinality as the "gap set" $\sup(ran(f))\setminus ran(f)$. (The key point here is that this gap set is at most size $\vert S\vert$ - do you see why?) We copy $f$ itself onto $S_0$, and "fill in the gaps" greedily on $S_1$, to get a function $f^*$ which has downwards-closed range and is equi-definable with $f$.