in reply to Re^2: Range check with unordered limits
in thread Range check with unordered limits

> 1) Isn't that equivalent to:

No, your version fails the limits when they are swapped

Here a generalized test suite for everyones experiments:

use v5.12; use warnings; our ($a,$b,$x); for my $lim ( [2,4], [4,2] ) { ($a,$b) = @$lim; for $x (1..5) { my @r = (&s0,&s1); unless ( $r[0] == $r[1] ) { say "fails for $x in [@$lim] with <$r[0]>,<$r[1]>"; } } } sub s0 { ($x > $a == $x < $b) || $x == $a || $x == $b; } sub s1 { $x >= $a == $x <= $b; }

c:/tmp/pm/clever_intervall.pl fails for 2 in [4 2] with <1>,<> fails for 4 in [4 2] with <1>,<>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery