From: martindemello@... (Martin DeMello) Date: 2002-11-19T20:29:10+09:00 Subject: Re: ruby-dev summary 18711-18810 "Aleksei Guzev" wrote in message news:... > "Minero Aoki" wrote in message > news:20021118181718N.aamine@mx.edit.ne.jp... > > Hi all, > > > > This is a summary of ruby-dev ML in these days. > > > > [ruby-dev:18651] Enumerable#zip (contd.) > > > > Aplying zip as an instance method to the module Enumerable makes the method > assymetric. There is the object left to the method name, and its parameters. > But in mind the operation is symmetrical except the order is significant. > Where should the object be placed in sequence? OTOH, the reason I don't like Kernel#zip is that it implies a false symmetry which breaks in the case len(a) < len(b). What I'd expect in the two cases would be a = [1,2,3] b = [5,6,7,8,9] a.zip(b) # => [[1,5], [2,6], [3,7]] zip(a,b) # => [[1,5], [2,6], [3,7], [nil,4], [nil,5]] I still think a zipf (zip with function) would be useful too a.zipf {|i| f} # => [[a1, f(a1)], [a2, f(a2), ...] Frinstance the Schwartzian transform could then be written def stsort(&block) zipf(&block).sort(a[1] <=> b[1]}.map(|a| a[0]} end martin