sub signatures coming

Paul Makepeace paulm at paulm.com
Tue Feb 25 16:17:13 GMT 2014


On Feb 25, 2014 7:16 AM, "James Laver" <james.laver at gmail.com> wrote:
>
>
> On 25 Feb 2014, at 11:31, Matt Lawrence <matt.lawrence at virgin.net> wrote:
>
> > On 25/02/14 11:18, James Laver wrote:
> >>
> >> But I probably already have List::MoreUtils imported (because Perl).
> >>
> >> sub pairwise_sum ($a1, $a2) {
> >>   zip @$a1, @$a2;
> >> }
> >>
> >> And lets ignore the fact that the perl version that was used in the
article was buggy. If $arg2 is shorter than $arg1 it breaks. zip's supposed
defined behaviour is to stop when either list runs out of elements.
> >
> > Whereas this one is buggy because it doesn't actually do what it says
on the tin. Where's the summation?
> >
> > Matt
>
> Ah yes. I'd just woken up.
>
> sub pairwise_sum($a2,$a2) {
>   map {shift($_)+shift($_)} (zip @$a1, @$a2);
> }

You aren't making a good case for perl here :)

>
> James


More information about the london.pm mailing list