[ create a new paste ] login | about

Link: http://codepad.org/zFeSAYjP    [ 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
package Recall;

sub recall {
    shift->(@_);
}

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

local $\ = "\n";
print recallable_sub {
    my $recall = shift;
    $_[0] <= 1 ? 1 : $_[0] * $recall->recall( $_[0] - 1 );
}($_) for (1..9);


Output:
1
2
3
4
5
6
7
8
9
1
2
6
24
120
720
5040
40320
362880


Create a new paste based on this one


Comments: