Extracted from Pike v7.8 release 866 at 2016-11-06.
pike.ida.liu.se
[Top]
Function

Method Function.Y()


Method Y

function Y(function f)

Description

The dreaded fixpoint combinator "Y".

The Y combinator is useful when writing recursive lambdas. It converts a lambda that expects a self-reference as its first argument into one which can be called without this argument.

Example

This example creates a lambda that computes the faculty function.

Function.Y(lambda(function f, int n) { return n>1? n*f(n-1) : 1; })