Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: TIMTOWTDI, synergy

by John M. Dlugosz (Monsignor)
on Jun 02, 2009 at 19:02 UTC ( #767734=note: print w/ replies, xml ) Need Help??


in reply to TIMTOWTDI, synergy
in thread How A Function Becomes Higher Order

Let me continue by pointing out that in Perl 6 you would not write max as a list operator or function. Rather, write it as an infix (2-argument) function, and the system will automatically generate the matching reduction operator. Or, write the reduction operator yourself if that's more efficient, but use the reduction syntax:

sub infix:<max> (::Type $left, Type $right --> Type) { return $left after $right ?? $left !! $right; } sub prefix:<[max]> (::Type *$first, Type *@rest --> Type) { ... }
That leaves off the details of how to make it a chaining operator (I guess max chains through normal association) and declaring its level of precedence and associativity, etc.


Comment on Re: TIMTOWTDI, synergy
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-08-23 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls