Self-recursion and arrow functions

Axel Rauschmayer axel at rauschma.de
Sun Mar 17 12:11:54 PDT 2013


Nice (in an IIFE-kind of way). If we had `do` expressions, the following would also be possible (producing an expression that could be assigned anywhere and to anything):

    do {let fact = n=>n>1 ?n*fact(n-1):1}

I’m assuming that the completion value of a let declaration is the rhs of the last assignment. Otherwise, `; fact` would have to be appended.

On Mar 17, 2013, at 19:24 , Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:

> I don't think anybody has yet exploited the power of parameter default values for defining recursive functions:
> 
>    ((fact=n=>n>1 ?n*fact(n-1):1)=>(fact))()

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130317/6ed77b2f/attachment.html>


More information about the es-discuss mailing list