Issue #10903 has been updated by marcandre (Marc-Andre Lafortune).


Wow, time flies. Sorry for not addressing this earlier.

I have some commits ready to address this: https://github.com/ruby/ruby/pull/1746

Naming: The issue I have with `zip` is not really the potential incompatibility, but that the builtin `zip` (at least in my head) does a kind of transposition, while it wouldn't for matrices (or it would do two, if you want to see it this way). Also, `Array#zip` is lax on sizes (you can zip arrays of different sizes). Finally, I would imagine that the result of `zip` for Matrices will *always* be chained with `map`, while `Array#zip` has other uses (`keys.zip(values).to_h`).

So I'm proposing `combine` instead, that takes a block (or returns an Enumerable).

What do you think?

----------------------------------------
Feature #10903: [PATCH] Matrix#zip returns a matrix
https://bugs.ruby-lang.org/issues/10903#change-67732

* Author: LitoNico (Lito Nicolai)
* Status: Assigned
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
* Target version: 
----------------------------------------
Currently:
    > x = Matrix.I 2
    > x.zip x
    => [[1, 1], [0, 0], [0, 0], [1, 1]] # It's an array!

With the patch:
    > x.zip x
    => Matrix[[1, 1], [0, 0], [0, 0], [1, 1]]

And also:
    > x.zip x, x  # and so on
    => Matrix[[1, 1, 1], [0, 0, 0], [0, 0, 0], [1, 1, 1]]


---Files--------------------------------
matrix_zip.patch (1.42 KB)


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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>