From: Joel VanderWerf Date: 2010-10-28T04:28:31+09:00 Subject: Re: Extraction of single subarrays from multidimensional array On 10/27/2010 05:05 AM, Maurizio Cirilli wrote: > (1) extract subarrays from a md-arrays (but the number of subarrays > can vary from case to case) I'm not sure I've understood what you're looking for, but it might be useful to look into the NArray gem. NArrays can store multidimensional data (not just numeric data) and slice-and-dice that data in a boggling variety of ways. An example: >> a = NArray.object(2,3,4).indgen => NArray.object(2,3,4): [ [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ], [ [ 6, 7 ], [ 8, 9 ], [ 10, 11 ] ], [ [ 12, 13 ], [ 14, 15 ], [ 16, 17 ] ], [ [ 18, 19 ], ... >> a[0,1,2] = "hello" => "hello" >> a => NArray.object(2,3,4): [ [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ], [ [ 6, 7 ], [ 8, 9 ], [ 10, 11 ] ], [ [ 12, 13 ], [ "hello", 15 ], [ 16, 17 ] ], [ [ 18, 19 ], ... >> a[0,1,1..2] => NArray.object(2): [ 8, "hello" ] >> a[0,1,true] => NArray.object(4): [ 2, 8, "hello", 20 ] >> a[0,true,2] => NArray.object(3): [ 12, "hello", 16 ]