Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^8: index of the minimum element of the array

by ikegami (Pope)
on Jan 20, 2014 at 15:32 UTC ( #1071330=note: print w/replies, xml ) Need Help??


in reply to Re^7: index of the minimum element of the array
in thread index of the minimum element of the array

For reduce, no. It's not documented. It's a side-effect of the implementation you tested.

For map, yes. map is a not a subroutine; it's an operator. It's not constrained to the syntax and convention of subroutine calls Its argumentoperand is not a sub.

I also see coderef passed to the sub when run under debugger. But not when run normally.

It's easy to see by using return inside the block. It's also easy to see using -MO=Concise.

$ perl -MList::Util=reduce -MO=Concise,-exec -e'reduce { "..." } @a' ... 4 <0> pushmark sRM 5 <$> anoncode[CV ] lRM 6 <1> refgen KM/1 7 <#> gv[*a] s 8 <1> rv2av[t4] lKM/1 9 <#> gv[*reduce] s a <1> entersub[t5] vKS/TARG,1 ... {15} eric@dev-eric [~/work/p4/src/main/CC] $ perl -MList::Util=reduce -MO=Concise,-exec -e'&reduce(sub { "..." }, + @a)' ... 4 <0> pushmark sRM 5 <$> anoncode[CV ] lRM 6 <1> refgen lKM/1 7 <#> gv[*a] s 8 <1> rv2av[t4] lKM/1 9 <#> gv[*reduce] s a <1> entersub[t5] vKS/TARG,AMPER,1 ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1071330]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-07-25 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (363 votes). Check out past polls.