Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 ...


Comment on Re^8: index of the minimum element of the array
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1071330]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2014-08-31 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls