RosettaCodeData/Task/Nth-root/Erlang/nth-root-1.erl
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

6 lines
255 B
Erlang

fixed_point(F, Guess, Tolerance) ->
fixed_point(F, Guess, Tolerance, F(Guess)).
fixed_point(_, Guess, Tolerance, Next) when abs(Guess - Next) < Tolerance ->
Next;
fixed_point(F, _, Tolerance, Next) ->
fixed_point(F, Next, Tolerance, F(Next)).