On Jan 30, Robin Sheat said:

>I have a function that takes a fairly complex set of arguments, and am
>wondering if there is a better way of doing this than the way I have
>done. A call to the function, as I have it, looks like:
>
>$network->potentiateWeights('network',1,(0,0,0,
>                                         1,2,3,
>                                         3,2,2));
[snip]
>sub potentiateWeights {
>    my $self = shift;   # for the OO-ness
>    my $net = shift;
>    my $delta = shift;
>    my (@src, @dest, @layer);

Here, you could make sure that @_ % 3 == 0, which insures that triplets
were indeed sent.  But, based on your code below:

>    while (@_) {
>        push @src, shift;
>        push @dest, shift;
>        push @layer, shift;
>    }

since @src = (0,1,3), @dest = (0,2,2), and @layer = (3,2,2), wouldn't it
make more sense to pass the triplets as array references like so:

  $network->pW(network => 1, [0,1,3], [0,2,2], [3,2,2]);

  sub pW {
    my $self = shift;
    my ($net, $delta, $src, $dest, $layer);
    # and then deal with @$src, @$dest, @$layer
  }

That'd be my strategy.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to