Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: recursive anonymous subroutines

by Anonymous Monk
on Apr 06, 2006 at 21:18 UTC ( #541740=note: print w/ replies, xml ) Need Help??


in reply to recursive anonymous subroutines

Maybe you'd be interested in the Y combinator.

#!/usr/bin/perl -w use strict; print "5! = ", Y(sub{ my ($proc, $n) = @_; ($n < 2) ? 1 : $n * $proc->($proc,$n-1) }, 5), "\n"; sub Y { my ($p, $x) = @_; $p->($p,$x); }


Comment on Re: recursive anonymous subroutines
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2015-07-29 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls