6. Given $A=\{1,-1, \mathrm{i},-\mathrm{i}\}$ (i is the imaginary unit), $f(x)$ is a function with domain and range both being $A$, for any $x, y \in A$, there is $f(x y)=f(x) f(y)$. Then the number of functions $f(x)$ that satisfy the condition is $\qquad$.


6. 2 .

Notice that, the domain and range of $f(x)$ are both finite sets $A$. Therefore, $f(x)$ is a bijection.
Let $x=y=1$, then $f(1)=f(1) f(1)$.
By $f(1) \neq 0$, hence $f(1)=1$.
Let $x=y=-1$, then $f(1)=f(-1) f(-1)$.
By $f(1)=1$, hence $f(-1)= \pm 1$; and since $f(x)$ is a bijection, thus, $f(-1)=-1$.
Therefore, when $f(i)=i$, $f(-i)=-i$;
when $f(-i)=i$, $f(i)=-i$.
Hence, there are 2 functions that satisfy the conditions.