Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 contemplating the Monastery: (5)
As of 2014-08-30 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls