From: "Kroeger, Simon (ext)" Date: 2005-10-11T21:38:10+09:00 Subject: Re: Sort pseudo-lists > -----Original Message----- > From: pete boardman [mailto:pete.boardman@pobox.com] > Sent: Tuesday, October 11, 2005 2:27 PM > To: ruby-talk ML > Subject: Re: Sort pseudo-lists > > One more thing - I forgot that I need to get the result back to a > string... So (thanks to your help andn Ruby's 'eval') I can go from > this: > > "{{3.1, 1.3, 2.5, 2.1}, {2.1, 3.1, 2.4, 2.2}, {1.4, 2.2, 2.1, 4.2}}" > > to this: > > [[1.4, 2.2, 2.1, 4.2], [2.1, 3.1, 2.4, 2.2], [3.1, 1.3, 2.5, 2.1]] > > but I can't persuade the 'p' method to turn this back into a string: > > "[[1.4, 2.2, 2.1, 4.2], [2.1, 3.1, 2.4, 2.2], [3.1, 1.3, 2.5, 2.1]]" > > (and I should be able to go from here to : > > "{{1.4, 2.2, 2.1, 4.2}, {2.1, 3.1, 2.4, 2.2}, {3.1, 1.3, 2.5, 2.1}}" > > on my own :-) > > > Pete a = [[1.4, 2.2, 2.1, 4.2], [2.1, 3.1, 2.4, 2.2], [3.1, 1.3, 2.5, 2.1]] puts '{{' + a.map{|b| b.join(', ')}.join('}, {') + '}}' =>{{1.4, 2.2, 2.1, 4.2}, {2.1, 3.1, 2.4, 2.2}, {3.1, 1.3, 2.5, 2.1}} cheers Simon