Daniel Gibson:

> Don't know about Python, but in D this will only be true if X is an integer.
> I guess 1<X<4 is true for X=1.5 in Python.. it would certainly not be true 
> for X
> in 1..4 in D.

You are right, the semantics is different, my silly mistake. Thank you.


> Also using X in 1..4 is in D is pretty bad if you just want to check if 1<X<4
> (or even more when checking 1<X<100) because it has a much higher overhead -
> even though it may be technically O(1) because 4 or 100 is a constant)

Even if the bounds are not constants it's not hard to perform  x in a..b  in 
O(1).

Bye,
bearophile

Reply via email to