[ruby-core:96016] [Ruby master Feature#4539] Array#zip_with

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-82857.20191128082340.95efd22ef303164c@ruby-lang.org>
Issue #4539 has been updated by matz (Yukihiro Matsumoto).


* The name `zip_with` is too confusing with `zip`. We need a new name.
* The behavior can be described by the combination of `zip` and `map`.
* I am not sure how much we need this behavior (yet).

Matz.



----------------------------------------
Feature #4539: Array#zip_with
https://bugs.ruby-lang.org/issues/4539#change-82857

* Author: citizen428 (Michael Kohl)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Inspired by Haskell's `zipWith` function, I hacked on together for Ruby:

```ruby
[1,2,3].zip_with([6,5,4], :+) #=> [7, 7, 7]
[1,2,3].zip_with([6,5,4]) { |a,b| 3*a+2*b } #=> [15, 16, 17]
```

So far I only have a Ruby version of it:

https://gist.github.com/731702b90757e21cadcb

My questions:

1. Would this method be considered a worthwhile addition to `Array`?

2. I've never hacked on the C side of Ruby (read some parts of the source though) and my C is quite rusty. I'd like to change that, would somebody be willing to help me turn this into a proper patch?





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.