[ create a new paste ] login | about

Link: http://codepad.org/g2L7KMQI    [ raw code | output | fork ]

Perl, pasted on May 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package Recall;

sub recall {
    $_[0]->(@_);
}

sub recallable_sub(&) {
    my $coderef = shift;
    my $obj = bless($coderef);
    sub { $obj->recall(@_) };
}

recallable_sub {
    my $recall = shift;
    my $c = shift;
    print "$c \n";
    $recall->recall($c) if ($c --);
}->(10);


Output:
1
2
3
4
5
6
7
8
9
10
11
10 
9 
8 
7 
6 
5 
4 
3 
2 
1 
0 


Create a new paste based on this one


Comments: