- or download this
sub sum{ ( shift()//return 0 ) + &sum }
...
print sum( 1 .. 100 );;
Deep recursion on subroutine "main::sum" at
5050
- or download this
print Y( sub{my$rec=shift; sub{(shift()//return 0) + &$rec }})->(1 ..
+100);;
5050
- or download this
sub Y {
my ( $curried_rec ) = @_;
...
$curried_rec->( sub { $f2->( $f2 )->( @_ ) } )
} )
}
- or download this
C:\test>perl -Mstrict -wE"say eval join'+',()"
...
C:\test>perl -Mstrict -wE"say eval join'+',-1..+3"
5