(printf "%s\n\n" ,
(begin
(matrix = (Array.new))
(ncols = 1)
(matrix.push(Array.new))
(((IO.readlines'/home/george/test.data').
map { | line | (line.strip) }).
each { | item | (if (item == "")
(ncols = (ncols + 1))
(matrix.push(Array.new))
else
((matrix.at(ncols - 1)).push item)
end)
})
(height = ((matrix.map { | column | (column.size) }).max))
(widths = (matrix.map { | column | ((column.map { | cell |
((sprintf("%s" , cell)).size) }).max) }))
((((matrix.map { | column | (column + (Array.new((height -
(column.size)) , ""))) }) .
transpose).
map { | row | ((([ row , widths ].transpose).
map { | r , w | (sprintf( "%*s" , w , r)) }) .
join ",")}).
join "\n")
end))
produces an error:
in `sprintf': no implicit conversion from nil to integer (TypeError)
--
Posted via http://www.ruby-forum.com/.