--8323328-1953287026-11290450712197
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1953287026-1129045071=:12197"
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-1953287026-11290450712197
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Wed, 12 Oct 2005, Martin DeMello wrote:
> Peter v. N. <skull2crush / hotmail.com> wrote:
>>
>> I know there exist "simple" ways (Google's thy friend)
>> to create md arrays with Ruby. But it's somehow cumbersome
>> and it would be nice if it could be done like "array = Array.new(3,3)"
>> -> I know too that this means not the same in Ruby...
>>
>> What I like to know: what led to the decission to do it that way
>> and not like it is done in the C/C++ (Java) languages la
>> "int[][] arr = new int[3][3]"?
>
> There are several different kinds of multidimensional arrays. One is
> true rectangular arrays (efficient memory allocation, bounds checked in
> every dimension) - I think FISh supports those[1], and probably Matlab
> as well.
>
> Then there's C's rectangular arrays with weak (no!) bounds checking -
> the array is allocated as a contiguous block, and multidimensional
> indexes are converted into (computed) single dimensional offsets into
> the block.
>
> And finally, Ruby uses the lists-of-lists approach, in which you have
> only one-dimensional arrays, but every cell of those arrays can be an
> array itself (and so on recursively). Not as efficient as the
> rectangular approach, but it allows for irregularly shaped arrays.
probably worth noting here that narray provides a syntheiss of both, with
copious numerical and array based methods added to boot.
cheers.
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
--8323328-1953287026-11290450712197--
--8323328-1953287026-11290450712197--