Re: Sort pseudo-lists
- From: ES <ruby-ml@xxxxxxxxxxxxxxx>
- Date: Wed, 12 Oct 2005 04:51:12 +0900
pete boardman wrote:
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:
Kernel#p actually prints stuff, using #inspect rather than #to_s. So, my_array.inspect will give you the below 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 :-)
Yep, just do the exact inverse of how you got the normal Array syntax. Why do you need to translate it back to the same form, though?
Pete
E
.
- References:
- Sort pseudo-lists
- From: pete boardman
- Re: Sort pseudo-lists
- From: pete boardman
- Sort pseudo-lists
- Prev by Date: Re: comments found in ObjectSpace
- Next by Date: Installing a gem locally (RubyForge.org unreachable)
- Previous by thread: Re: Sort pseudo-lists
- Next by thread: Re: Sort pseudo-lists
- Index(es):
Relevant Pages
|