Thanks Steve.  <br><br>Long time no hear from you.<br><br>Jay<br><br><div class="gmail_quote">On Thu, Dec 3, 2009 at 8:54 AM, Steven Lembark <span dir="ltr">&lt;<a href="mailto:lembark@wrkhors.com">lembark@wrkhors.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
&gt; If I have a 10x10 array of arrays like:<br>
&gt;<br>
&gt; [40 8 79 8 73 71 77 35 12 67]<br>
&gt; [4 79 10 90 45 17 30 29 65 86]<br>
&gt; [56 86 5 34 23 79 17 83 24 85]<br>
&gt; [58 85 46 53 15 31 34 4 14 15]<br>
&gt; [68 15 97 21 81 95 71 82 26 90]<br>
&gt; [59 70 11 82 39 25 36 84 88 13]<br>
&gt; [66 6 85 1 84 17 27 58 60 94]<br>
&gt; [34 10 38 90 32 0 56 14 23 70]<br>
&gt; [71 23 5 97 4 71 27 20 11 87]<br>
&gt; [5 8 23 30 97 16 10 93 16 67]<br>
&gt;<br>
&gt; Is there any notation I can use to get &quot;column 1&quot;, i.e. $a[0][0], $a[1][0],<br>
&gt; $a[2][0]... without looping over the whole structure<br>
&gt;<br>
&gt; I need to find the max value in each column<br>
&gt;<br>
&gt; I know how to do it in a loop, but I thought maybe there was some neato way<br>
&gt; in a slice.<br>
<br>
</div>Not really: &quot;slices&quot; are sequential within the<br>
array. Since you have a collection of separate<br>
arrays a slice does not apply.<br>
<br>
If you have to do this regularly, an alternative<br>
is storing the data in a single list and taking<br>
every Nth item:<br>
<br>
    @big_array[ 0, 10, 20, 30, ... ]<br>
<br>
will take the first item out of a 10x10 array,<br>
<br>
    @big_array [ 0 .. 9 ]<br>
<br>
will take the first row.<br>
<br>
This is more-or-less the way that languages with<br>
multi-dimensinal arrays handle the issue, but is<br>
a pain to manage yourself by hand if the language<br>
doesn&#39;t deal with stride issues for you.<br>
<br>
It also requires that you pre-size the array, which<br>
isn&#39;t always easy or effecient.<br>
<br>
If you regularly have to slice the data, it may<br>
be effective to store it in a hash:<br>
<br>
    $data{ $x, $y } = $value;<br>
<br>
This also helps in cases where you regularly have<br>
sparse data. You can &quot;slice&quot; the data by factoring<br>
out the interesting keys:<br>
<br>
    grep { /$x ; .*/x } keys %data;<br>
<br>
will grab a given x value,<br>
<br>
    grep { /.* $; $y/x } keys %data;<br>
<br>
will grab a given y value.<br>
<br>
That or you can buffer the keys onto arrays when<br>
they are first used and then just use:<br>
<br>
<br>
    my @col_valz = max @data{ @{ $col_keyz[$col] } };<br>
<br>
or<br>
<br>
    my @row_valz = max @data{ @{ $row_keyz[$row] } };<br>
<br>
For a moderately small matrix or somewhat sparse<br>
matrix that is frequently sliced this actually<br>
works pretty well -- at the expense of setting up<br>
the column and row key arrays once.<br>
<br>
Otherwise, as usual, map is your friend :-)<br>
<font color="#888888"><br>
--<br>
Steven Lembark                                            85-09 90th St.<br>
Workhorse Computing                                 Woodhaven, NY, 11421<br>
<a href="mailto:lembark@wrkhors.com">lembark@wrkhors.com</a>                                      +1 888 359 3508<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
</div></div></blockquote></div><br>