fix(challenges): Y problem
This commit is contained in:
@ -6,31 +6,17 @@ challengeType: 5
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
<section id='description'>
|
<section id='description'>
|
||||||
<p>
|
In strict <a href="https://en.wikipedia.org/wiki/Functional programming" title="wp: functional programming" target="_blank">functional programming</a> and the <a href="https://en.wikipedia.org/wiki/lambda calculus" title="wp: lambda calculus" target="_blank">lambda calculus</a>, 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.
|
||||||
In strict
|
The <a href="http://mvanier.livejournal.com/2897.html" target="_blank">Y combinator</a> 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 <a href="https://en.wikipedia.org/wiki/Fixed-point combinator" title="wp: fixed-point combinator" target="_blank">fixed-point combinators</a>.
|
||||||
<a href="https://en.wikipedia.org/wiki/Functional programming" title="wp: functional programming">functional programming</a> and
|
|
||||||
the <a href="https://en.wikipedia.org/wiki/lambda calculus" title="wp: lambda calculus">lambda calculus</a>,
|
|
||||||
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.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
The <a href="http://mvanier.livejournal.com/2897.html">Y combinator</a> 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
|
|
||||||
<a href="https://en.wikipedia.org/wiki/Fixed-point combinator" title="wp: fixed-point combinator">fixed-point combinators</a>.
|
|
||||||
</p>
|
|
||||||
Task:
|
|
||||||
|
|
||||||
Define the stateless Y combinator function and use it to compute
|
|
||||||
<a href="https://en.wikipedia.org/wiki/Factorial" title="wp: factorial">factorial</a>.
|
|
||||||
|
|
||||||
<code>factorial(N)</code> function is already given to you.
|
|
||||||
See also <a href="http://vimeo.com/45140590">Jim Weirich: Adventures in Functional Programming</a>.
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
<section id='instructions'>
|
<section id='instructions'>
|
||||||
|
Define the stateless Y combinator function and use it to compute <a href="https://en.wikipedia.org/wiki/Factorial" title="wp: factorial">factorial</a>. The <code>factorial(N)</code> function is already given to you.
|
||||||
|
<b>See also:</b>
|
||||||
|
<ul>
|
||||||
|
<li><a href="http://vimeo.com/45140590" target="_blank">Jim Weirich: Adventures in Functional Programming</a>.</li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
Reference in New Issue
Block a user