Skip to main content
4 of 4
added 23 characters in body
flawr
  • 43.9k
  • 7
  • 104
  • 249

MATLAB, 41 bytes

function x=g(f,x);while f(x)-x;x=f(x);end

There is also this beauty that does not need function files. Unfortunately it is a little bit longer:

i=@(p,c)c{2-p}();g=@(g,f,x)i(f(x)==x,{@()x,@()g(g,f,f(x))});q=@(f,x)g(g,f,x)

Try it online!

flawr
  • 43.9k
  • 7
  • 104
  • 249