On Tue, Apr 01, 2008 at 05:39:36AM -0400, Mark J. Reed wrote:
> On Tue, Apr 1, 2008 at 1:44 AM, Xiao Yafeng <[EMAIL PROTECTED]> wrote:
> > I've read Synopsis and I wondered why to treat max and min as
> >  operator. IMHO, view them as list functions is more reasonable. Like
> >  below:
> >
> >  @test.max
> 
> Which is how you would probably call it in Perl6.  Or else
> 
> max(@test)
> >
> >  is clearer than
> >
> >  @test[0] max @test[1]  or [max] @test.
> 
> Which is not legal Perl6. "max" and "min" may be called "operators",
> but that doesn't mean they're INFIX operator.  

"min" and "max" are infix operators in Perl 6.  From Synopsis 3:

: * Minimum and maximum
:
:     $min0 min $min1
:     $max0 max $max1

I think they're defined as operators because of some of the
other features one can get from it, beyond just the [max] reduction:

    $c = $a max $b;          # versus $c = ($a, $b).max;

    $d max= $e;              # versus $d = ($d, $e).max;

    @c = @a »max« @b;        # larger element of @a and @b

    @e = @a »max» 100;       # each element is at least 100

Pm

Reply via email to