in reply to Array indices
Your indices function sounds sorta like the smart match code that I heard theDamian talk about at his Perl6 talk -- well, at least knowing whether "heimer" is in the list.
Of course, you could write your own indices() function pretty quickly, using a sort of modification of the Schwartzian Transform (I actually have tested this, on a few cases, but let me know if I've missed anything):
sub indices ($@) { # note the prototype has target, then list my $target = shift; my (@list) = @_; my $index = 0; map { $_->[1] } grep { $_->[0] eq $target } map { [$_ , $index++] } @list; }
I'm sure some wizard out there could tighten this up, but I think it's pretty clear what I'm aiming at.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Array indices
by Aristotle (Chancellor) on Sep 14, 2002 at 06:00 UTC |
In Section
Seekers of Perl Wisdom