Re: Sort pseudo-lists



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



.



Relevant Pages

  • Re: internationalisation
    ... affects the whole string (like replacing all vowels with accented ... variants). ... And translate what bothers you most. ...
    (microsoft.public.vc.mfc)
  • Re: Musings on a holiday weekend
    ... If the native coding of U/OS is to be UTF-16, I'd expect that all of the files would also have to be UTF-16. ... CLST - Compare Logical STring ... MVCLE - MoVe Character Long Extended ... TRTR - TRanslate and Test Reverse ...
    (bit.listserv.ibm-main)
  • Re: namespaces
    ... >> import string ... >> No pollution. ... namespace pattern instances ... >> def translate(text) ...
    (comp.lang.python)
  • Re: Problem with -3 switch
    ... refers to prepending a u to strings to make them unicode objects, ... It's not designed to translate arbitrary 2.6 code, ... to talk about string constants specifically, ...
    (comp.lang.python)
  • Re: Ada to C++ translator
    ... > of Ada. ... The data sheet focuses on type conversions between Ada and C++. ... which is the same as the C string type. ... There is also no indication they can translate concurrent programs. ...
    (comp.lang.ada)