Front page | perl.perl6.language |
Postings from June 2005
nested subs
Thread Next
From:
Piers Cawley
Date:
June 16, 2005 15:17
Subject:
nested subs
Message ID:
m2k6kuhrq4.fsf@obelisk.bofh.org.uk
So, I was about to write the following test for Pugs:
sub factorial (Int $n) {
my sub factn (Int $acc, $i) {
return $acc if $i > $n;
factn( $acc * $i, $i+1);
}
factn(1, 1);
}
When I thought to check the apocalypses and exegeses and, what do you know, I
couldn't find any evidence that nested named functions like this were legal.
So, are they legal?
And yes, I know there are other ways of doing this, but I like the lack of
sigils on the function when you do it this way.
Thread Next
-
nested subs
by Piers Cawley