[Chicago-talk] Array slices

Jay Strauss me at heyjay.com
Sun Nov 5 12:09:41 PST 2006

> Do you consider "map" to be iteration?
> Jay> For example, I'd like to create a slice out of the 2nd element of each
> Jay> inner array, so that my result would be (2,4,6).
> Jay> @a = ([1,2],[3,4],[5,6]);
> Jay> print join @a[][1],"\n";  # doesn't work
> Jay> print join @a[0..2][1],"\n"; #doesn't work
> my @a = ([1,2],[3,4],[5,6]);
> my @result = map $_->[1], @a;
> print "@result\n";

I do consider it to be an iterator.  I'm actually already using map,
but I thought there may be some niffy syntax that would do it for me.

mine looks like:  my @attributes  = map {$_->[1] } @parm_defs;

I guess I could leave off the braces, and add a comma :)


More information about the Chicago-talk mailing list