sub signatures coming

James Laver james.laver at gmail.com
Tue Feb 25 11:27:49 GMT 2014


On 25 Feb 2014, at 11:18, James Laver <james.laver at gmail.com> 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.
> 
> James

Oh, for bonus fun, I’d do it a different way in clojure (using a map):

(def pairwise-sum zipmap)

You might also have fun assuming clojure.zip[1] has anything to do with the zipmap function. If you actually figure out what a ‘zipper’ is, do please let me know because it’s been evading me for about a year.

James

1. http://clojuredocs.org/clojure_core/clojure.zip/zipper


More information about the london.pm mailing list