in reply to Finding the max()/min()
Here's a pair I like, similar to your delightfully symmeteric third example,
Those are slightly forthish, in lifting a logical value to arithmetic use.# max my $max = ($x, $y)[$x < $y]; # min my $min = ($x, $y)[$x > $y];
Update: As subroutines,
I used prototypes there because the usual perl min and max extracts the extreme of a list, instead of from just two values.sub max ($$) { $_[$_[0] < $_[1]] } sub min ($$) { $_[$_[0] > $_[1]] }
After Compline,
Zaxo
In Section
Meditations