Open eakravchenko opened 4 years ago
Yeah, that's why we have &&
and ||
and shortcut boolean evaluation in most languages.
Apart from mild inconvenience of introducing lazy evaluation into the interpreter, I wanted people to stumble here, and appreciate that trait of other languages.
So, what solution do you propose?
If witth double condition i can rewrite for two if. But what should i do with while i < len & x[i] <= 0: it cannot be rewritten with two while!
You can use a boolean-like variable to simulate that, like:
ok := 1
while ok:
ok &= i < len
if ok:
ok &= x[i] <= 0
if ok:
...
I agree it's very inconvenient though.
If a & b cheks all conditions, even a is false. Therefore, you need to write a if(r>=0): if(x[r]>=0): instead of if(r>=0 & a[r] ):
It is very uncomfortable.