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