Hello All,

I like to rephrase my problem below by the following interactive 
session:
>> x =  "1, 12, 500"
=> "1, 12, 500"
>>  a = x.split(",").map {|k| k.to_i}
=> [1, 12, 500]
>> y = "[25.0, 26], [30, 31]"
=> "[25.0, 26], [30, 31]"
>> b = y.split(",").map {|k| k.to_i}
=> [0, 26, 0, 31]

I get what I want in the 4th line, an array of numbers
I don't get, nor did I expect to, what I want in the last line, i.e., an 
array of arrays.
How can I convert to an array of arrays?

Thanks,


Peter Versteegen wrote:
> Hi,
> 
> I have been following this list off and on but have not found the
> solution to my problem. I want to convert data supplied by a file into
> their corresponding internal values.
> 
> I have an external file with data that are in the form "variable name",
> tab,  followed by their value.  The 'value 'can be a single number, an
> array of numbers, or a matrix of numbers,   For example, the file might
> look like this:
> a  2.4
> b  1,0, 3.0, 5.0
> c  5, 6, 11
> d  [1, 2], [5, 6], [45,55]
> e     2*[7, 8]
> 
> I can get a, b, and c to convert to single values and arrays, thanks to
> this forum, but I cannot figure out a way to convert d into an array of
> arrays. I haven't taclked e yet. Does anyone have any suggestions?
> 
> Ideally I would like to match the variable name in the file to the
> corresponding and same name already coded in the program.  Any ideas how
> to do that?
> 
> Thanks
> 
> Pete Versteegen


-- 
Posted via http://www.ruby-forum.com/.