From: Pen Ttt on 1 May 2010 21:59 there is text1 1,2,3,4 1,2,3 1,2 1,2,3,4,5 what i want to get is text2: 1,1,1,1 2,2,2,2 3,3, 3 4, 4 5 how to get it ? -- Posted via http://www.ruby-forum.com/.
From: Brian Candler on 2 May 2010 04:36 Pen Ttt wrote: > there is text1 > 1,2,3,4 > 1,2,3 > 1,2 > 1,2,3,4,5 > what i want to get is text2: > 1,1,1,1 > 2,2,2,2 > 3,3, 3 > 4, 4 > 5 Is this what you want? >> a = [[1,2,3,4,nil],[1,2,3,nil,nil],[1,2,nil,nil,nil],[1,2,3,4,5]] => [[1, 2, 3, 4, nil], [1, 2, 3, nil, nil], [1, 2, nil, nil, nil], [1, 2, 3, 4, 5]] >> a.transpose => [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, nil, 3], [4, nil, nil, 4], [nil, nil, nil, 5]] -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: a ruby 1.8.5 list of ruby VM's Next: Sendmail, semicolons and new lines |