fp::fixedpt
-- returns fixed
point of a functionfp::fixedpt
(f)
returns the fixed point of
the unary function f
.
fp::fixedpt(f)
f |
- | unary function |
A unary function.
fp::fixedpt
returns the fixed point of the unary
function f
.fp::fixedpt
is implemented as the Y
combinator which is defined as follows:
Y := f -> g(f)(g(f))where the function g is defined as
g := f -> (h -> (x -> f(h(h))(x)))
A function computing the Fibonacci numbers is created as a fixed point:
>> fb2 := (f,n) -> if n <= 2 then 1 else f(n-1) + f(n-2) end: fib := fp::fixedpt(fp::curry(fb2)): fib(i) $ i=1..9
1, 1, 2, 3, 5, 8, 13, 21, 34