On Thu, Feb 24, 2011 at 06:59:02PM -0500, Steven W. Orr wrote:
> I intentionally used the star instead of the atsign because I'm taking 
> advantage of the fact that these array elements all have no whitespace. So, 
> after the assignment to a_all, the value of a[0] is equal to the single 
> string represented by "${a1[*]}" (with quotes).

So you're trying to make an array of arrays?  To fake a two-dimensional
matrix?  Should've said so.

The only sane way to do this is to make an associative array whose
keys are a tuple of the indices you want.  (Or, if the indices are
strictly numeric, and bounded, you can do it with regular sparse
non-associative arrays by making the keys i*100+j where 100 is some
constant chosen to be larger than the bound on j.)

And, of course, there's always "don't write it in bash".  That's often
a sane answer.

AA example:

  declare -A big
  big[$i,$j]=foo

Numeric index example:

  big[i*100+j]=foo

If you actually wanted an "array of lists" or something that's *not*
mimicking a matrix, then, well, good luck.  (Did I mention that there
are other languages besides bash?  Some of them actually HAVE such data
structures.)

Reply via email to