[Chicago-talk] Array Slices - of columns

Jay Strauss me at heyjay.com
Thu Dec 3 13:17:43 PST 2009


Hi Paul, yeah that's how I've been doing it (roughly).  It works fine, I
just thought there might be some nifty syntax.

Thanks
Jay

On Wed, Dec 2, 2009 at 8:27 PM, Paul Mantz <pcmantz at gmail.com> wrote:

> On Wed, Dec 2, 2009 at 7:38 PM, Jay Strauss <me at heyjay.com> wrote:
> > Hi All, hope you had a nice thanksgiving.
> >
> > If I have a 10x10 array of arrays like:
> >
> > [40 8 79 8 73 71 77 35 12 67]
> > [4 79 10 90 45 17 30 29 65 86]
> > [56 86 5 34 23 79 17 83 24 85]
> > [58 85 46 53 15 31 34 4 14 15]
> > [68 15 97 21 81 95 71 82 26 90]
> > [59 70 11 82 39 25 36 84 88 13]
> > [66 6 85 1 84 17 27 58 60 94]
> > [34 10 38 90 32 0 56 14 23 70]
> > [71 23 5 97 4 71 27 20 11 87]
> > [5 8 23 30 97 16 10 93 16 67]
> >
> > Is there any notation I can use to get "column 1", i.e. $a[0][0],
> $a[1][0],
> > $a[2][0]... without looping over the whole structure
> >
> > I need to find the max value in each column
> >
> > I know how to do it in a loop, but I thought maybe there was some neato
> way
> > in a slice.
> >
> > Thanks
> > Jay
> >
> > _______________________________________________
> > Chicago-talk mailing list
> > Chicago-talk at pm.org
> > http://mail.pm.org/mailman/listinfo/chicago-talk
> >
>
> I don't know how you'd go about doing it with slices, but I like using
> map for things like this.
>
> map { $_->[$col] } @grid;
>
> will pretty much give you what you're looking for.
>
> --
> Paul Mantz
> http://www.mcpantz.org
> BackupPC - Network Backup with De-Duplication http://www.backuppc.com
> Zmanda - Open source backup and recovery http://www.zmanda.com/
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20091203/eded4c05/attachment.html>


More information about the Chicago-talk mailing list