in reply to Re^6: index of the minimum element of the array
in thread index of the minimum element of the array
Fair enough. However, the sub is called with inherited @_ and it happens to work.
Same thing with map:
Can I not rely on this behavior?sub foo { map { print $_[$_] } 0 .. $#_ }
Update. example code:
This is perl 5, version 12, subversion 3 (v5.12.3) built for x86_64-linux-thread-multiuse List::Util 'reduce'; sub minindex { reduce { $_[$a] < $_[$b] ? $a : $b } 0 .. $#_ } my @g = (55, 88, 33, 6, 234, 234, 52, 6, 1324, 22, 1234); print minindex @g; # $g[7] == 6
List::Util $VERSION = "1.22";
Update2. One final observation:
I also see coderef passed to the sub when run under debugger. But not when run normally.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: index of the minimum element of the array
by ikegami (Patriarch) on Jan 20, 2014 at 15:32 UTC | |
Re^8: index of the minimum element of the array
by LanX (Saint) on Jan 17, 2014 at 19:53 UTC | |
Re^8: index of the minimum element of the array
by LanX (Saint) on Jan 17, 2014 at 20:23 UTC |
In Section
Seekers of Perl Wisdom