Python Tuple Comparison not working for multiple less than, more than -


i have 3d coordinate tuple (x, y, z). want test none of 3 co-ords of given tuple below (a, b, c) , none higher (d, e, f). through trial, error, , reading these forums i've learned that:

(a, b, c) <= (x, y, z) <= (d, e, f)

doesn't work first expression evaluates, gets outcome (0 or 1) , uses in next evaluation, , on. tried:

((a, b, c) <= (x, y, z)) , ((x, y, z) <= (d, e, f))

this doesn't work either because when hits true in of 3 paired comparisons (a, x; b, y; c, z; etc), results in true. such, tuple comparisons work more decimal values rather 3 separate scalar variables. need failure of 3 pair-comparisons (six in total) produce false result rather success produce true.

i hoped method sweetly simple <= b <= c. simple method of doing tuples produces true when pair-wise comparisons pass?

assuming lower , upper bound point three-tuples, try this:

lower = 1,2,3 upper = 5,2,7 xyz = 2,3,4  all(u <= j <= v u, j, v in zip(lower, xyz, upper)) 

or compare them individually:

(a <= x <= d) , (b <= y <= e) , (c <= z <= f) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -