From: "alexeymuranov (Alexey Muranov)" Date: 2012-08-14T03:48:17+09:00 Subject: [ruby-core:47158] [ruby-trunk - Feature #6852] [].transpose should behave specially Issue #6852 has been updated by alexeymuranov (Alexey Muranov). marcandre (Marc-Andre Lafortune) wrote: > > The later would fail for an empty set of exams and grades I didn't understand this sentence. Anyway, i just want to give another explanation why it is possible to assume that there is only one empty matrix. With this assumption the function of #transpose will become correct, as [] == [[]] == [[],[],[]] == ... (as matrices). One of the ways to define a matrix is as an m x n rectangular table of numbers, more precisely a function from {0, ..., m-1} x {0, ..., n-1} to the numbers. If m or n is equal to 0, then the domain is the empty set, and so is the only function on this domain: {} x {} = {} x {0,1,2} = {0,1,2} x {} = {} = ���, and the only function define on ��� is ���. I used here set theoretic conventions. Of course matrices can also be viewed as functions from R^m to R^n, then R^0 = {���}, and "empty matrices" of different dimension will not be the same. But i think this view point is less standard. Alexey. ---------------------------------------- Feature #6852: [].transpose should behave specially https://bugs.ruby-lang.org/issues/6852#change-28840 Author: boris_stitnicky (Boris Stitnicky) Status: Open Priority: Normal Assignee: Category: core Target version: 2.0.0 p = [1, 2, 3] q = [4, 5, 6] [p, q].transpose # => [[1, 4], [2, 5], [3, 6]] As expected, 2 x 3 vector was converted into 3 x 2. [p].transpose # => [[1], [2], [3]] As expected, 1 x 3 => 3 x 1. [].transpose # => [] Unexpected, 0 x 3 did not become 3 x 0: [[], [], []] In other words, when [] is the receiver, transpose has no way to know what kind of ** 2 dimensional ** object is it - whether 0 x 3, 0 x 4, 0 x 1 or perhaps 0 x 0. #transpose should not assume it is 0 x 0. It should raise, or warn, or complain, or require argument for this case, in short, it should behave differently than today. -- http://bugs.ruby-lang.org/