From: Dr.Ruud on
Ben Morrow wrote:

> (Now, of course, I'm wondering about a '<=' operator, which isn't the
> usual 'less-than-or-equal' operator but instead a compare-and-assign
> operator like ||=... It's hard to see what it might sensibly be called.)


$x = min( $x, $y, $z, ... );

$x min= $y, $z, ...;

$x->min( $y, $z, ...);


Of course you often have a running minimum:

$x = min( $x, $min );

$x min= $min;

$x->min( $min );


--
Ruud
From: Ted Zlatanov on
On Fri, 13 Aug 2010 18:34:01 +0200 "Dr.Ruud" <rvtol+usenet(a)xs4all.nl> wrote:

R> $x = min( $x, $y, $z, ... );

R> $x min= $y, $z, ...;

R> $x->min( $y, $z, ...);

The second one is best.

But I think it's much better to treat this as a general stats problem.
_ caches the stat call, so why not cache list stats too if requested?

cache_stats(@list, qw/min avg median stdev/);

min(@list); # fast

push @list, min(@list) -1;

min(@list); # automatically updated

max(@list); # slow, not cached

This is not so good if you have lots of small updates, that's why it
should be optional. I don't think it can be done in Perl 5.

Ted