I thought it would be interesting if the conditions had the optimization I present below.
There could be a simplification for these two situations:
1st => equality
2º => inequality
If we have "and" and "or" together, this not apply.
Hi Yuri,
I have no clue what you try to explain as idea. Could you give more detail or examples?
Regards,
Daniel
Hi @Daniel Kuhlmann
My ideia is to have an easier way to make if conditions in this two cases: conditions with only "or"s or only "and"s.
Imagine if we have a conditions like:
A = 1 or A = 2 or A = 3 or A = 4 or A = 5
I think we can improve this to:
A = (1 or 2 or 3 or 4 or 5), it is easier to write, avoid repeting "A"s and "="s.
The same thing to conditions with only and:
A <> 1 and A <> 2 and A <> 3 and A <> 4 and A <> 5 to
A <> (1 and 2 and 3 and 4 and 5)
Hi @Yuri Fontes ,
you are proposing to somehow shorthand certain combinations of (in)equality and boolean operators, make them take on a different functionality dependant on the context they exist in ?
I've never heard of such a thing, do you know of any programming languages that allow this ?
This goes against simple (math) rules of how to interpret a logical expression, and as such, I think it would decrease readability, not increase it.
If you feel you need this because your expression is too long / repetitive, than maybe you need to think of other solutions than a long condition ? Maybe use some list or string holding all the options and index/search into that. Can't really say without knowing exactly what you are trying to solve.
Dorine
Hi @Dorine Boudry
The idea I proposed is not to solve a problem but to simplify a solution.
The idea does not go against mathematical rules. In mathematics, there is the simplification of terms, for example:
5 * a + 5 * b - 5 * c = 5 * (a + b - c).
My suggestion goes in the same direction as the simplification of terms we were taught in mathematics: A = 1 or A = 2 or A = 3 => A = (1 or 2 or 3).
I believe that the fact that it doesn't exist in other languages is not a reason for it not to be integrated. There is always space for innovation.
Regards, Yuri Fontes.
your example is from arithmatic no boolean algebra
i never seen this type of thing with boolean operators
Hi @Yuri Fontes.
I think you're suggestion something like the IN operator in SQL.
Instead of doing:
A = 1 OR A = 2 OR A = 3
Doing something like:
A in (1, 2, 3)
Or instead of:
A <> 1 AND A <> AND OR AND <> 3
A NOT IN (1, 2, 3)
Is that what you're proposing?
Thanks.
Hi @Dawud M.
That's exactly it.
Thank you