X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FSub%2FNary.pm;h=4b87e45bc779c0fd4a9c9a3e110b2816c95b8a1b;hb=19271bbd36d8b5346d323f6e47038b9abff33a91;hp=ec00eb18a72e3280c048cda6b7f2e75ed63dfd68;hpb=157f26dab3f210aee4c9a2d4c90230e2af3b0713;p=perl%2Fmodules%2FSub-Nary.git diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index ec00eb1..4b87e45 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -28,7 +28,7 @@ BEGIN { use Sub::Nary; - my $sn = Sub::Nary->new(); + my $sn = Sub::Nary->new; my $r = $sn->nary(\&hlagh); =head1 DESCRIPTION @@ -39,11 +39,15 @@ This module uses the L framework to walk into subroutines and try to guess ho =head2 C + my $sn = Sub::Nary->new; + The usual constructor. Currently takes no argument. -=head2 C +=head2 C + + my $res = $sn->nary($coderef); -Takes a code reference to a named or anonymous subroutine, and returns a hash reference whose keys are the possible numbers of returning scalars, and the corresponding values the "probability" to get them. The special key C<'list'> is used to denote a possibly infinite number of returned arguments. The return value hence would look at +Takes a reference to a named or anonymous subroutine, and returns a hash reference whose keys are the possible numbers of returning scalars, and the corresponding values the "probability" to get them. The special key C<'list'> is used to denote a possibly infinite number of returned arguments. The return value hence would look at { 1 => 0.2, 2 => 0.4, 4 => 0.3, list => 0.1 } @@ -91,7 +95,7 @@ it is considered to return C<3> scalars with probability C<1/2>, C<2> with proba The total probability law for a given returning point is the convolution product of the probabilities of its list elements. -As such, +As such, sub notsosimple { return 1, simple(), 2