https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112011-07-18T22:29:50ZRuby Issue Tracking SystemRuby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=192962011-07-18T22:29:50ZEregon (Benoit Daloze)
<ul></ul><p>Hi,</p>
<p>Please have a look at <a href="http://redmine.ruby-lang.org/issues/4539" class="external">http://redmine.ruby-lang.org/issues/4539</a> (or <a href="/issues/4539">[ruby-core:35613]</a>).</p>
<p>The reason is explained by Yusuke in <a href="/issues/4539">[ruby-core:35682]</a>:</p>
<blockquote>
<p>2011/4/5 Benoit Daloze <a href="mailto:eregontp@gmail.com" class="email">eregontp@gmail.com</a>:</p>
<blockquote>
<p>An unconditional nil is anyway not useful here, the only concern I see<br>
might be the cost of creating this Array.</p>
</blockquote>
<p>It is actually a problem.<br>
I have used Array#zip with block for iteration many times.</p>
<p>big_ary1.zip(big_ary2) do |x, y|<br>
p [x, y]<br>
end</p>
<p>The change requires some people (including me) to <em>rewrite</em><br>
such a code as follows:</p>
<p>big_ary1.size.times do |i|<br>
x, y = big_ary1[i], big_ary2[i]<br>
...<br>
end</p>
<p>So I like zip_with, if it is really needed.</p>
</blockquote>
<p>That issue kind of got lost, it is probably a good idea to continue it.</p>
<p>For your example, we could have [1,2,3].zip_with([1,2,3], :+)</p> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=251522012-03-25T17:02:37Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>Currently it can be implemented as follows.</p>
<p>% ruby -e 'p [1,2,3].zip([1,2,3]).map {|a,b| a + b }'<br>
[2, 4, 6]<br>
% ruby -e 'p [1,2,3].lazy.zip([1,2,3]).map {|a,b| a + b }.to_a'<br>
[2, 4, 6]</p> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=251532012-03-25T17:03:19Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=332472012-11-20T21:46:41Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Target version</strong> set to <i>2.6</i></li></ul> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=686992017-12-25T18:15:00Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.6</i></del>)</li></ul> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=704842018-02-20T08:47:01Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p>We cannot change the behavior. The change would increase the memory consumption (and decrease the performance).</p>
<p>Matz.</p> Ruby master - Feature #5044: #zip with block return mapped resultshttps://bugs.ruby-lang.org/issues/5044?journal_id=822532019-10-22T22:48:48Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-6 priority-4 priority-default closed" href="/issues/16261">Feature #16261</a>: Enumerable#each_splat and Enumerator#splat</i> added</li></ul>