The persistence of a number \$x = d_1d_2d_3...d_n\$, with \$d_1 \ne 0\$, under some function \$f : \mathbb N_0 \times \mathbb N_0 \to \mathbb N_0\$ is defined as the number of applications of \$f\$ to the digits of \$x\$ before it reaches a single digit integer. That is, if we have the map
$$I_f: (x = d_1d_2d_3...d_n) \mapsto f(f(...f(d_1, d_2), d_3), ...), d_n),$$
the persistence is defined as
$$P_f(x) = \begin{cases} 0, & x \in \{0,1,2,3,4,5,6,7,8,9\} \\ 1 + P_f(I_f(x)), & \text{otherwise} \end{cases}$$
Some examples include:
- Additive persistence: \$P_+(2718) = 2\$, \$P_+(5) = 0\$ and \$P_+(2677889) = 3\$
- Multiplicative persistence: \$P_\times(68889) = 7\$, \$P_\times(25) = 2\$ and \$P_\times(8) = 0\$
- Minimal/maximal digit: \$P_{\min}(1734) = 1\$, \$P_{\max}(48203) = 1\$ and \$P_{\min}(5) = 0\$
Given a blackbox function \$f : \mathbb N_0 \times \mathbb N_0 \to \mathbb N_0\$ and a positive integer \$x = d_1d_2d_3...d_n\$, where \$d_i\$ are digits with \$d_1 \ne 0\$, output the persistence of \$x\$ under \$f\$.
You may assume that \$f\$ will eventually reach a single digit number when repeatedly applied to \$x\$'s digits.
This is a code-golf challenge, so shortest code wins.
Test cases
f(x, y), x -> output
x + y, 2677889 -> 3
x × y, 68889 -> 7
x ** y, 29 -> 4
φ(x × y), 736 -> 2 (φ is the Euler Totient function)
x/2 + (x × y), 1234567 -> 5 (using floor division)
|x - y|, 9 -> 0