RosettaCodeData/Task/Y-combinator/00DESCRIPTION

14 lines
1,014 B
Text
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
In strict [[wp:Functional programming|functional programming]] and the [[wp:lambda calculus|lambda calculus]], functions (lambda expressions) don't have state and are only allowed to refer to arguments of enclosing functions.
This rules out the usual definition of a recursive function wherein a function is associated with the state of a variable and this variable's state is used in the body of the function.
2013-04-11 01:07:29 -07:00
The [http://mvanier.livejournal.com/2897.html Y combinator] is itself a stateless function that, when applied to another stateless function, returns a recursive version of the function. The Y combinator is the simplest of the class of such functions, called [[wp:Fixed-point combinator|fixed-point combinators]].
2016-12-05 22:15:40 +01:00
;Task:
Define the stateless Y combinator and use it to compute [[wp:Factorial|factorials]] and [[wp:Fibonacci number|Fibonacci numbers]] from other stateless functions or lambda expressions.
2013-04-11 01:07:29 -07:00
;Cf:
* [http://vimeo.com/45140590 Jim Weirich: Adventures in Functional Programming]
2016-12-05 22:15:40 +01:00
<br><br>