B
Bill Birkett
I did like to convert some programs I wrote in Perl to Ruby. I'm
working with sparse three dimensional data. Here's an example in
Perl. The array @a has just two elements. The rest are undefined.
#!/usr/bin/perl -w
$a[0][0][0] = 0;
$a[100][100][100] = 100;
print "$a[0][0][0]\n";
print "$a[100][100][100]\n";
The output:
0
100
Is there an easy way to implement this sort of data structure in
Ruby? The Array class seems limited to one dimension. I looked at the
Matrix class, but there doesn't appear to be any way of assigning
values to the individual matrix elements (which seems pretty strange,
so maybe I'm overlooking the obvious).
-Bill
--
William B. Birkett - <[email protected]>
Print Quality Consultant
Doppelganger, LLC - http://www.doplganger.com/
48799 Meadow Drive, Plymouth, MI 48170 (USA)
Office: (734) 927-4232 FAX: (734) 468-0580
Cell: (734) 516-4790
working with sparse three dimensional data. Here's an example in
Perl. The array @a has just two elements. The rest are undefined.
#!/usr/bin/perl -w
$a[0][0][0] = 0;
$a[100][100][100] = 100;
print "$a[0][0][0]\n";
print "$a[100][100][100]\n";
The output:
0
100
Is there an easy way to implement this sort of data structure in
Ruby? The Array class seems limited to one dimension. I looked at the
Matrix class, but there doesn't appear to be any way of assigning
values to the individual matrix elements (which seems pretty strange,
so maybe I'm overlooking the obvious).
-Bill
--
William B. Birkett - <[email protected]>
Print Quality Consultant
Doppelganger, LLC - http://www.doplganger.com/
48799 Meadow Drive, Plymouth, MI 48170 (USA)
Office: (734) 927-4232 FAX: (734) 468-0580
Cell: (734) 516-4790